Coplien's form tells you to overload the operator =
. It's easy when your class has no const
attributes but when it does it's more complicated.
class MyClass {
public:
MyClass( MyClass const & src );
MyClass( void );
MyClass( name, age, leggedness );
~MyClass( void );
// Member functions etc...
private:
std::string const _name;
int const _number_of_leg;
int _age;
// other const and non-const attributes...
}
What is the best way of overloading the operator =
for that kind of class ? Both keeping and not keeping const
attributes values from source.