[讨论]C++类练习
#include<iostream>
using namespace std;
class V
{ public:
void V_putin();
void V_putout();
private:
float length;
float width;
float height;
float V_v(float,float,float);
}v1,v2,v3;
void main()
{ v1.V_putin();
v1.V_putout();
}
void V::V_putin()
{ cout<<"请输入长方体的长、宽、高:";
cin>>length>>width>>height;
cout<<endl;
}
float V::V_v(float a,float b,float c)
{ float y;
y=a*b*c;
return y;
}
void V::V_putout()
{ cout<<"长、宽、高分别是:"<<length<<','<<width<<','<<height<<endl<<"该长方体的体积是:"<<V_v(length,width,height)<<endl;
}