| Author |
copy constructor
|
Pritam Chatterjee
Greenhorn
Joined: Jul 31, 2011
Posts: 13
|
|
|
how and why to use copy constructors? Example
|
Pritam
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32599
|
|
To create an object identical to the original one.
To prevent the original being altered.Rather than returning the “real” account, you are returning a copy. That allows code to play with the account object without altering the original account object.
|
 |
Pritam Chatterjee
Greenhorn
Joined: Jul 31, 2011
Posts: 13
|
|
|
thanks..
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32599
|
|
You’re welcome
|
 |
 |
|
|
subject: copy constructor
|
|
|