Taking care of the Color
As it happens (because we took a ready-made, thoroughly designed class), the Color class already supports the assignment (=) operator. This makes it easy to take care of the Color in the “operator=“ member function:
// the assignment operator
cube& cube::operator= (const cube& c)
if ( this == &c) return (*this) ;
Beware: *color = *c.color is different from color = c.color !
Here we invoke the operator=
member function function of the Color object. (We make an actual copy of the object).
here we just copy the pointer, something we don’t want.