Search code examples
c++oopoperator-overloadingassignment-operator

What is the difference between overloading the assignment operator and any other operator?


I want to know if there is any difference between simple binary operator overloading and assignment operator overloading.


Solution

  • Here are two differences:

    1. An overloaded assignment operator must be a member of the class being assigned to; it cannot be declared as a free function.
    2. Copy and move assignment operators will be implicitly declared for your class if you do not declare them yourself (subject to certain restrictions).