C++ Tutorial:

C++ Copying vs Assignment


  • Copy Constructor
  • MyClass( const MyClass& other );
  • MyClass( MyClass& other );
  • MyClass( volatile const MyClass& other );
  • MyClass( volatile MyClass& other );
  • Assignment Constructor
  • MyClass& operator=( const MyClass& rhs );
  • MyClass& operator=( MyClass& rhs );
  • MyClass& operator=( MyClass rhs );
  • const MyClass& operator=( const MyClass& rhs );
  • const MyClass& operator=( MyClass& rhs );
  • const MyClass& operator=( MyClass rhs );
  • MyClass operator=( const MyClass& rhs );
  • MyClass operator=( MyClass& rhs );
  • MyClass operator=( MyClass rhs );


rhsRight Hand Side of the equality for both copy and assignment constructors. For example the assignment constructor : MyClass operator=( MyClass& rhs );


Other Good Resources for further research :

What's the difference between assignment operator and copy constructor?

assignment operator vs. copy constructor C++


C++ Articles

C++ Copying vs Assignment Examples:

Related C++ Tutorial Topics:

Other Tutorial Topics:

This modified content is an extract of the original Stack Overflow Documentation released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow. This topic was created and modified by the Stack Ovedrflow Contributor.