#include
{
public:
Retangle(void);
double Volume(void);
double Area(void);
void SetValue(double length, double width, double height);
private:
double length;
double width;
double height;
};Retangle :: Retangle(void)
{
length = 0.0;
width = 0.0;
height = 0.0;
}double Retangle :: Volume(void)
{
return (length * width * height);
}double Retangle :: Area(void)
{
return (2 * (length * width + length * height + width * height));
}void Retangle :: SetValue(double length, double width, double height)
{
this -> length = length;
this -> width = width;
this -> height = height;
}int main(int argc, char *argv[])
{
double length;
double width;
double height;
Retangle retangle;
cout << "Please input lenght, width and height:" << endl;
cin >> length >> width >> height;
retangle.SetValue(length, width, height);
cout << "Volume: " << retangle.Volume() << endl;
cout << "Area: " << retangle.Area() << endl;
return (0);
}
#include
using namespace std;
class CFT{
public:
CFT(double a,double b,double c){
ma=a;
mb=b;
mc=c;
}
void output(){
cout<<"V="<cout<<"S="<<(ma*mb+ma*mc+mb*mc)*2< return;
}
private:
double ma,mb,mc;
};
class Cuboid
{private: double length; double width; double height;public: Cuboid()
{
}
Cuboid(double len,double wid, double hei): length(len),width(wid),height(hei)
{
} double getVolume()
{
return length*width*height;
}
double getArea()
{
return 2*(length*width + length*height + width*height);
}
};
使用方法:Cuboid test(1,2,3);cout << "体积:" << test.getVolume() <