I have a function like this:
void foo(int optionalinteger=0, float optionalfloat=0.0f, cell *optionalarray=NULL)
{
return;
}
I tried to acces an optional argument like
foo(.optionalfloat=5.5f); // from another programming language
but that gives an error.
How do I access only the optional value I choose to without the need to supply other optional values?
If you really want to, you can use something akin to the named parameter idiom, e.g.:
That’s quite a lot of work for something quite simple and counter-intuitive if you’re not really expecting to see something like that in your code base.
Or you could use the boost named parameter library if you prefer.