Named parameters: Difference between revisions
Content added Content deleted
(→{{header|Ruby}}: Show the future: MRI 2.0.0dev (2012-01-04 trunk 34211).) |
|||
Line 98: | Line 98: | ||
You wrap the parameters in a class, and make the function a friend of the parameter class. |
You wrap the parameters in a class, and make the function a friend of the parameter class. |
||
<lang |
<lang cpp>class foo_params{ |
||
friend void foo(foo_params p); |
friend void foo(foo_params p); |
||
public: |
public: |
||
Line 128: | Line 128: | ||
Declare the function to take the parameter class as its only parameter. |
Declare the function to take the parameter class as its only parameter. |
||
<lang |
<lang cpp>void foo(foo_params p){ . . .}</lang> |
||
Call the function using the parameter object constructor with the required parameters and chaining the optional parameters. |
Call the function using the parameter object constructor with the required parameters and chaining the optional parameters. |
||
<lang |
<lang cpp>foo(foo_params(42).x(7).z(23.54));</lang> |
||