Copy constructor with more than one parameter
Posted
by
Ravi Gupta
on Stack Overflow
See other posts from Stack Overflow
or by Ravi Gupta
Published on 2012-06-08T05:27:34Z
Indexed on
2012/06/08
10:40 UTC
Read the original article
Hit count: 276
c++
|copy-constructor
I am learning C++ and was reading copy constructor from the C++: The Complete Reference
. The books says that
It is permissible for a copy constructor to have additional parameters as long
as they have default arguments defined for them. However, in all cases the first
parameter must be a reference to the object doing the initializing.
But I am confused that how we are going to pass those additional parameters? I am sure there should be some way which is not given in the book and which I am unable to figure out. Can anyone help me out?
EDIT: Also is it possible to pass these extra parameters in all three cases i.e.
¦ When one object explicitly initializes another, such as in a declaration
¦ When a copy of an object is made to be passed to a function
¦ When a temporary object is generated (most commonly, as a return value)
© Stack Overflow or respective owner