I am new to C ++ programming, so please don't be too harsh :). The minimum description of my problem is illustrated by the following example. Let's say I have this function declaration in the header file:
int f(int x=0, MyClass a);
The compiler complains that parameters following a parameter with a default value must also have default values.
But what is the default value for the second parameter?
The idea is that a function could be called with less than two arguments if the rest is not specific, so all of the following should go:
MyClass myObj; // create myObj as an instance of the class MyClass int result=f(3,myObj); // explicit values for both args
int result=f(3); // explicit for first, default for second arg
int result=f(); // defaults for both
source share