class Point
{public:
Point(int a,int b){ x=a; y=b;}
Point(){x=0;y=0;}
int GetY(){return y;}
int GetX(){return x;}
void SetY(int b){ y=b;}
void SetX(int a){ x=a;}
private:
int x;
int y;
};
#include<iostream>
#include<cmath>
#define _CRT_SECURE_NO_WARNINGS //这个宏定义最好要放到.c文件的第一行
#pragma warning(disable:4996)
using namespace std;
class Point
{
public:
Point(int a, int b) { x = a; y = b; }
Point() { x = 0; y = 0; }
int GetY() { return y; }
int GetX() { return x; }
void SetY(int b) { y = b; }
void SetX(int a) { x = a; }
private:
int x;
int y;
};
class Rectangle :public Point
{
public:
Rectangle(int x1, int y1, int x2, int y2) :p1(x1, y1), p2(x2, y2)
{
s = fabs((x1 - x2) * (y1 - y2));
}
void display()
{
cout << "左上角顶点为(" << p1.GetX() << "," << p1.GetY() << ")" << endl;
cout << "右下角顶点为(" << p2.GetX() << "," << p2.GetY() << ")" << endl;
cout << "面积是: " << s;
}
private:
Point p1, p2;
int s;
};
int main()
{
Rectangle rectangle(1, 1, 5, 5);
rectangle.display();
return 0;
}