Question : C++ : Avoid ambiguous copy constructor error

My C++ project has a class with a simple copy constructor which works the usual way: It is given one parameter, which is a (const) reference to an instance of its own class, and it copies the member variables from it into the object being created.

Now I want to add another variant of a copy constructor to the class; it's first parameter is the same as before, but in addition to that it should have additional parameters with default values.

The compiler gives an error about ambiguous constructors, when the constructor is called with only one parameter. That makes sense because it doesn't know which of the copy constructors to use.

How can I introduce the new "extended copy constructor" with default parameters without having to change the numerous occurrences where the copy constructor is invoked with one parameter?

Answer : C++ : Avoid ambiguous copy constructor error

>> Sorry I'm kind of lost now... mX and mY are not primitive types (but arrays of int), so they cannot be assigned in an initialization list, can they?

Sorry, you're probably right I didn't look at them specifically - although you'd be better off using vector as this can.
http://www.cplusplus.com/reference/stl/vector/

>> And I guess we still have the problem with ambiguity:
Why? there is no ambiguity the two constructors and unambiguous, it's only you putting the default value on there that is causing the issue.
Random Solutions  
 
programming4us programming4us