A copy constructor is a special constructor used to create a new object as a copy of an existing object. This constructor takes a single argument: a reference to the object to be copied.
A copy constructor is generally needed when an object owns pointers or non-shareable references such as to a file and then you usually need a destructor and assignment operator too.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment