Ok, ok, but what is it good for?
A pointer to an object of class “body” can now point to either a “cube” or a “cylinder” object; so we have a common “handle” for both of them:
p2 = new cylinder (2., 5.);
cout << "Volume: " << p1->GetVolume() << endl;
cout << "Surface: " << p1->GetSurface() << endl;
cout << "Volume: " << p2->GetVolume() << endl;
cout << "Surface: " << p2->GetSurface() << endl;
both p1 and p2 are “pointers to an object of class body”
the are assigned pointers to an object of type cube and cylinder, respectively.
Automatically the proper member functions of cube or cylinder are called.
If it is a body, it has functions GetVolume and GetSurface which we can call.