
182 C++ Programming
bool getSuccess()
{
return bSuccess;
}
void DisplayData()
{
float volume=getVolume();
float density=getDensity();
cout << "Type of Metal : " << metalType << 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);
float x=c1; // Conversion Operator called 1st time
cout << c1; // Conversion Operator called 2nd time
}
Output
Conversion of object of CuboidMetal into float value
Conversion of object of CuboidMetal into float value 10.5
In Program 4.6, object c1 is converted into float value twice:
(i) When c1 is assigned to