#include <iostream.h>
class CPoint
{
public:
CPoint(int m,int n)
{
x=m;
y=n;
}
int Getx()
{
return x;
}
int Gety()
{
return y;
}
private:
int x,y;
};
class Jx:private CPoint
{
public:
Jx(int m,int n,int x=0,int y=0):CPoint(m,n)
{
a=x;
b=y;
}
print()
{
int m,n;
m=Getx();
n=Gety();
cout<<"CPoint点的坐标是:("<<m<<','<<n<<")"<<" 派生矩形的另一点坐标为:("<<a<<","<<b<<")"<<endl;
cout<<"矩形的面积是:"<<(a-m)*(b-n)<<endl;
cout<<"矩形的周长是:"<<2*((a-m)+(b-n))<<endl;
}
private:
int a,b;
};
class line:private CPoint
{
public:
line(int m,int n,int x=0):CPoint(m,n)
{
c=x;
}
print()
{
int a;
a=Getx();
cout<<"CPont点x的坐标为: "<<a<<" 派生类x1的坐标为: "<<c<<endl;
cout<<"直线的距离是:"<<c-a<<endl;
}
private:
int c;
};
void main()
{
line B(3,4,5);
B.print();
cout<<endl;
Jx C(0,0,2,4);
C.print();
}