1

#include <iostream>

using namespace std;

class Point

{private:int x;int y;

public:Point(int a,int b){x=a;y=b;}};

class Rectangle

{friend class Point;

private:Point A;Point B;

public:Retangle(Point a,Point b):A(a),B(b){}


Retangle (Rectangle &p)

{A=p.A;B=p.B;}

int getArea()

{return (B.x-A.x)*(B.y-A.y);}};

int main()

{

Point p1(1,2),p2(3,4);

Rectangle juxing1(p1,p2);

Rectangle juxing2(juxing1);

cout<<juxing1.getArea()<<endl;

cout<<juxing2.getArea()<<endl;

return 0; 

}

全部评论

相关推荐

10-07 23:57
已编辑
电子科技大学 Java
八街九陌:博士?客户端?开发?啊?
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务