class

#include<iostream>
using namespace std;
class Box{
	private:
		double length;
		double width;
	public:
		void setLength(double length);
		void setWidth(double width);
		double getLength();
		double getWidth();
		double getArea();
};
void Box::setLength(double length){
	this->length=length;
}
void Box::setWidth(double width){
	this->width=width;
}
double Box::getArea(){
	return length*width;
}
double Box::getLength(){
	return length;
}
double Box::getWidth(){
	return width;
}
int main(){
	Box box;
	box.setLength(6.0);
	box.setWidth(7.0);
	cout<<box.getArea()<<endl;
	return 0;
}

  

posted @ 2024-01-27 09:02  陈若麟  阅读(3)  评论(0编辑  收藏  举报