Stats

56 Contributors: 2 Tuesday, November 8, 2016
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial: riptutorial@gmail.com
Roadmap: roadmap

Copying vs Assignment

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