1 Answers

In the C++ programming language, the assignment operator, =, is the operator used for assignment. Like most other operators in C++, it can be overloaded.

The copy assignment operator, often just called the "assignment operator", is a special case of assignment operator where the source and destination are of the same class type. It is one of the special member functions, which means that a default version of it is generated automatically by the compiler if the programmer does not declare one. The default version performs a memberwise copy, where each member is copied by its own copy assignment operator.

The copy assignment operator differs from the copy constructor in that it must clean up the data members of the assignment's target whereas the copy constructor assigns values to uninitialized data members. For example:

4 views

Related Questions