#include<iostream>
#include<stdlib.h>
using namespace std;
struct Rectangle
{
public:
Rectangle(int a, int b) : length(a), width(b){}
int area();
int perimeter();
private:
int length, width;
};
int Rectangle::area()
{
return(length * width);
}
int Rectangle::perimeter()
{
return(length + width);
}
int main(void)
{
struct Rectangle rect(10, 20);
cout << "area is:" << rect.area() << endl;
cout << "perimeter is:" << rect.perimeter() << endl;
system("pause");
return 0;
}
//只给你写个长方形的,其它自己想着做吧,这样的题目都不自己做的话,那还是不要学编程了