How exactly do default values in functions work? My question pertains to this example:
int func(int number, std::string name = "None", int anotherNumber);
..
int func(int number, std::string name, int anotherNumber){
...
}
func(1, 2);
^Error, name is NULL yet we've defined a default value?
The compiler gives an error complaining that the argument was NULL and should not be. Yet I've defined a default value for it.
Why is this?
Default arguments are last.
https://en.wikipedia.org/wiki/Default_argument