I have to write constructor with two default parameters.
func(int arg1 , char* arg2 = "arg2", int arg3 = 1) //example
I am provided the scenario where the constructor is called and a value is given to arg1
and arg2
and arg3
is expected to use a default value. Then another object is instantiated and a value is given to arg1
and arg3
, and default value for arg2
is expected to be used.
Now the problem is, you "can't skip" default parameters is what I'm reading from the text and online. It's saying to order the default paramters from its likliness of being overloaded, but the scenario has one default parameter used while the other isn't. The hints for this question tells me to reorder the parameters/arguments. However, no amount of reordering that I've done seem to be able to resolve this issue.
Also, overloaded constructors can not be used. This has to be done by one constructor.
So how would one do this? I'm stumped and going a bit crazy over this :(