return 0; }
int GetArea() { int t;
t= (R.GetX()-L.GetX())*(R.GetY()-L.GetY());
cout<<"The Area is "<<t<<endl; return 0; } private:
CPoint R,L; }; (3)
#include<iostream>
using namespace std;
class CPoint { public: CPoint() { x=0;
y=0; } int GetX() { return x; } int GetY() { return y; }
void SetX() {
cin>>x; }
void SetY() {
cin>>y; } private: int x,y;
};
class CRectangle { public:
CRectangle(const CPoint &a, const CPoint &b) { L=a; R=b; }
void SetRPoint() {
cout<<"Input the RPoint"<<endl; R.SetX(); R.SetY(); }
void SetLPoint() {
cout<<"Input the LPoint"<<endl; L.SetX(); L.SetY(); }
int GetPerimeter() { int s;
s= 2*(R.GetX()-L.GetX()+R.GetY()-L.GetY());
cout<<"The Perimeter is "<<s<<endl;
return 0; }
int GetArea() { int t;
t= (R.GetX()-L.GetX())*(R.GetY()-L.GetY());
cout<<"The Area is "<<t<<endl; return 0; } private:
CPoint R,L; }; int main() { CPoint L; CPoint R;
cout<<"Initialize the LPoint:"<<endl;
L.SetX(); L.SetY();
cout<<"Initialize the RPoint:"<<endl; R.SetX(); R.SetY();
CRectangle a_rectagnle(L,R);
a_rectagnle.GetPerimeter();
a_rectagnle.GetArea();
a_rectagnle.SetLPoint();
a_rectagnle.SetRPoint();
a_rectagnle.GetPerimeter();
a_rectagnle.GetArea(); return 0; }