Named parameters: Difference between revisions

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