
176 C++ Programming
void DisplayData()
{
float volume=getVolume();
float density=getDensity();
cout << "Type of Metal : " << metalType << endl;
cout << "Length is: " << length << endl;
cout << "Breadth is " << breadth << endl;
cout << "Height is " << height << endl;
cout << "Volume is: " << volume << endl;
cout << "Density is " << density << endl << endl;
}
};
int main()
{
CuboidMetal c1("Silver",10,9.5,2.8,2793,10.5);
++c1; //Calls operator++() (overloaded prefix operator)
c1.DisplayData();
}
Output
Type of Metal : Silver
Length is : 11
Breadth is : 10.5
Height is : 3.8
Volume is : 438.899994
Density is : 6.363636
4.6 More About new Keyword