Copy constructors
From cppreference.com
A copy constructor is used to initialize an object from another object of the same class.
When possible and no copy constructor is defined by the user,
the compiler will implicitly define a copy constructor which will call the copy constructor of all ancestors and members.
If an ancestor or member does not have a copy-constructor (this can also happen when some member is a reference).
[edit] Syntax
| class_name ( const class_name & ) | (1) | ||||||||
| class_name ( const class_name & ) = default; | (1) | ||||||||
| class_name ( const class_name & ) = delete; | (1) | ||||||||
[edit] Explanation
- Standard declaration of a copy constructor
- Forcing a copy constructor to be generated by the compiler
- Avoiding implicit default constructor
To make a class uncopyable in C++93, a declaration of a copy constructor must be present inside the private part of a class.
It can be left unimplemented and its only purpose is to make the compiler give errors on copying:
class C { private: C ( const C& ); // C cannot be copied };

