22 lines
358 B
C++
22 lines
358 B
C++
// 1. 2. 创建一个名为 Rectangle 的类,具有成员变量 width 和 height,以及成员函数 double calculateArea() ,用于计算矩形的面积。
|
||
#include <iostream>
|
||
|
||
using namespace std;
|
||
|
||
class Rectangle
|
||
{
|
||
public:
|
||
double calculateArea()
|
||
{
|
||
return width * height;
|
||
}
|
||
|
||
int width, height;
|
||
};
|
||
|
||
int main()
|
||
{
|
||
|
||
return 0;
|
||
}
|