01./* 02.* 程序的版权和版本声明部分 03.* Copyright (c)2013, 烟台大学计算机学院学生 04.* All rightsreserved. 05.* 文件名称: .cpp 06.* 作 者:赵冠哲 07.* 完成日期:2013年5月25日 08.* 版本号: v1.0 09.* 输入描述: 10.* 问题描述: 11.*/ #include <iostream> using namespace std; class Rectangle { public: Rectangle(float x1=0,float y1=0,float x2=0,float y2=0):a(x1),b(y1),c(x2),d(y2){} Rectangle operator+(Rectangle &p2); friend ostream& operator<<(ostream&,Rectangle&); void input(); private: float a; float b; float c; float d; }; Rectangle Rectangle::operator+(Rectangle &p2) { return Rectangle(a+p2.a,b+p2.b,c+p2.c,d+p2.d); } ostream& operator<<(ostream&output,Rectangle&p) { output<<(p.c-p.a)*(p.d-p.b)<<endl; return output; } void Rectangle::input() { cin>>a>>b>>c>>d; } int main() { Rectangle p1(1,1,6,3),p2,p3; p2.input(); p3=p1+p2; cout<<p3; return 0; }