📄 00022.cpp
字号:
/*
名称编号:00022
实现功能:矩形类完全模块化
运行结果:通过
*/
/***************************************************************************/
#include <iostream.h>
//声明矩形类
class Square
{
public:
void setdata(int NewL,int NewW);
void showdata();
private:
int Length,Wide;
};
//获取长宽函数的实现
void Square::setdata(int NewL,int NewW)
{Length=NewL;
Wide=NewW;
}
//内联函数实现显示功能
inline void Square::showdata()
{
cout<<"The area of the Square S="
<<Length<<'*'<<Wide<<"="
<<Length*Wide<<endl;
}
void main()
{
Square Area;
int NewL,NewW;
cout<<"Please enter the L&W:"<<endl;
cin>>NewL>>NewW;
Area.setdata(NewL,NewW);
Area.showdata();
}
/***************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -