天天看點

求長方體的體積C++代碼

#include<iostream>
using namespace std;

class V{
public:
	void set_value();
	void get_V();
	void show_V();
private:
	float length;
	float width;
	float height;
	float v;
};

void V::set_value()
{
	cin>>length;
	cin>>width;
	cin>>height;
}

void V::get_V()
{
	
	v=length*width*height;
}

void V::show_V()
{
	cout<<"V="<<v<<endl;
}

int main()
{
	V V1;
	V1.set_value();
	V1.get_V();
	V1.show_V();
	return 0;
}
           

繼續閱讀