Possible Duplicate:
behaviour of the implicit copy constructor / assignment operator
C++ - conditions for automatic generation of default ctor, copy ctor,and default assignment operator?
Is it true that the overloaded assignment operator is always provided by the C++ compiler? What are the cases in which it is not provided by the c++ compiler?
An Assignment/Copy Assignment(=
) operator is provided by any C++ compiler implicitly unless you have const
or reference members in your class.
In case of const
member compiler cannot provide =
because that would break the contract of not modifying const
member after initialization.
In case of reference member compiler does not provide =
because it leaves it to the user of the class to decide the appropriate behavior.