//仅供参考
#include<iostream>//求面积
#include<stdlib.h>
using namespace std;
class JuXing
{
private:
double l, x;
public:
JuXing(double a, double b) { l = a; x = b; }
void s()
{
cout<<l * x<<endl;
}
};
int main()
{
JuXing s1(20,50),s2(3.6,4.5);
cout<<"面积1=";
s1.s();
cout << "面积2=";
s2.s();
system("pause");
}
C++求矩形面积,定义类
最新推荐文章于 2024-08-16 07:15:00 发布