
274 C++ Programming
cout<<"Height"<<height<<endl;
MetalShape::DisplayData();
}
You can modify the DisplayData function of SphericalMetal class and execute Program 6.3.
6.3 Virtual Destructor
Do you feel that there is any memory leak in Program 6.3? You may say that all objects of
CuboidMetal and SphericalMetal class are created on stack; hence, there is no memory leak be-
cause when an object created on stack goes out of scope, the destructor of these objects are
automatically called. When m[0],m[1],m[2],m[3],m[4],m[5] goes out of scope, the destructor of
the base class is called. According to C++ standard, deleting a derived class object through ...