Well suppose there is a function
void fun(const MyStructure& argu1 = MyStructure(), MyStructure& argu2 = Mystructure())
argu2 isn’t const because I want to modify its value in the function.
To call the function:
MyStructure a;
MyStructure b;
fun(a,b);
The build succeeds in windows but fails in Linux and the error is
default argument for parameter of type 'MyStructure&' has type 'MyStructure'
But the build succeeds both in windows and in linux if I remove the second default argument which is non-const… Can anybody tell me why and how to solve it?
You can use overloading to let you manually handle an optional second non-const reference argument: