Wednesday, 17 May 2017

c++ - copy constructor parameters

In a copy constructor why do arguments need to have default values associated with them?
What happens if there are no default values associated with them and more than one argument is provided in the constructor?



For example:




X(const X& copy_from_me, int = 10);


has a default value for the int, but this:



X(const X& copy_from_me, int);


does not. What happens in this second case?




http://en.wikipedia.org/wiki/Copy_constructor

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...