#include<iostream>
using namespace std;
class Rectanglecalculator
{
private:
float length;
float width;
public:
void setlength(float length)
{
this->length=length;//赋值地址
}
void setwidth(float width)
{
this->width=width;
}
float rectangleCalculator()
{
return length*width;
}
double display()
{
return rectangleCalculator();//函数前加参数类型的可以不在括
//内写参数类型和参数,但必须写return
//void必须写参数类型和参数,可以不写return
}
};
int main()
{
Rectanglecalculator prt1;
prt1.setlength(12.3);
prt1.setwidth(2.3);
cout<<prt1.display();
return 0;
}
C# cass10 面积计算
2024-03-30 12:20:02 49 阅读