“cube c2 = c1” is different from “c2 = c1”!
The effect is the same, but what happens is quite different:
On the left, we saw that we are calling the operator= member function of object c2.
On the right, we construct the object c2 using c1. We are calling a special constructor, the so-called “copy constructor”, of c2, which gets a reference to the object to be copied (c1 in this case).
class cube : public body {
cube (const float, const Color *c);
virtual char* identify() const;
virtual float GetVolume() const;
virtual float GetSurface() const;
// the assignment operator
cube& operator= ( const cube & );
cube::cube (const cube& c)
Different from the operator member functions, the compiler will automatically generate a copy constructor whether you want it or not, and this is almost never what you really want.
The best is to always supply a copy constructor just to be safe.