源代码: #include<iostream> using namespace std; class Rectangel{ private: float length,width; public: float Init(float length,float width){ this->length=length; this->width=width; } float Area(){ return length*width; } float Perimeter(){ return 2*(length+width); } }; int main(){ Rectangel re; re.Init(10,10); cout<<"面积:"<<re.Area()<<endl; cout<<"周长:"<<re.Perimeter()<<endl; return 0; } ![]() |
|