#ifndef __RECT_H__
#define __RECT_H__
class Rectangle
{
private:
double x1,y1,x2,y2;
double lenth,wide;
public:
Rectangle(double xx1=0,double yy1=0,double xx2=0,double yy2=0);
Rectangle(const Rectangle &r);
void set(double xx1,double yy1,double xx2,double yy2);
void show() const;
Rectangle & operator +=(const Rectangle &r);
Rectangle & operator -=(const Rectangle &r);
Rectangle operator +(const Rectangle &r1);
//friend Rectangle operator +(const Rectangle &r1,const Rectangle &r2);
//一个双目运算符同时重载为类的成员函数和友元函数时.
//使用该运算符时系统会优先调用类的成员函数
Rectangle operator -(const Rectangle &r);
//Rectangle& operator =(const Rectangle &r);
};
#endif
c++成员与友元
最新推荐文章于 2024-09-04 13:45:30 发布