
204 C++ Programming
public:
SphericalMetal(char*n,float r, float m,float a)
{
strcpy(metalType,n);
radius=r;
mass=m;
accurate_density=a;
}
void DeterminePurity()
{
float d=getDensity();
if(d==accurate_density)
cout<<"Metal "<<metalType<<" is pure."<<endl;
else
cout<<"Metal "<<metalType<<" is not pure."<<endl;
}
};
int main()
{
CuboidMetal c[3]={
CuboidMetal("Silver",10,9.5,2.8,2793,10.5),
CuboidMetal("Gold",7.1,5.8,9.1,7103,19.3),
CuboidMetal("Platinum",3.5,2.7,1.8,189,21.4)
};
SphericalMetal s[3]={
SphericalMetal ("Silver",21,407484,10.5),
SphericalMetal ("Gold",42,5991955.2,19.3),
SphericalMetal ("Platinum",63,22423262.4,21.4)
};
for(int i=0;i<3;i ...