现在的位置: 首页 > 综合 > 正文

c++成员与友元

2013年12月09日 ⁄ 综合 ⁄ 共 565字 ⁄ 字号 评论关闭
#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

抱歉!评论已关闭.