⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rectangle.h

📁 c++小程序
💻 H
字号:
class Rectangle
{
	public:
		void Init(double Initx,double Inity);     //设定宽、高的初始值		
	    double GetWidth(){return Width;}	//得到宽度
	    double GetHeight(){return Height;}				//得到高度
		double Area(double Width,double Height){return Width*Height;}				//计算长方形的面积
	    void DispInfo();		//显示长方形的信息(包括宽、高和面积)
	private:
		double Width,Height,area;
		double SetWidth(double NewWidth);			//设定宽度
		double SetHeight(double NewHeight);				//设定高度
};
void Rectangle::Init(double Initx,double Inity)
{
	Width=SetWidth(Initx);
	Height=SetHeight(Inity);
}					 
double Rectangle::SetHeight(double NewHeight)
{
	Height=NewHeight;
	return Height;
}
double Rectangle::SetWidth(double NewWidth)
{
	Width=NewWidth;
	return Width;
}

void Rectangle::DispInfo()
{
	cout<<"求得长宽和面积为:\n";
	cout<<"长"<<GetWidth()<<"宽"<<GetHeight()<<"面积"<<Area(Width,Height)<<endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -