C++Copying vs Assignment

Download C++ for free

Syntax

  • 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 );

Parameters

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

Remarks

Other Good Resources for further research :

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

assignment operator vs. copy constructor C++

GeeksForGeeks

C++ Articles

Related Examples

Assignment Operator