2016年6月27日

C++ 运算符重载三(链式编程)

摘要: //运算符重载之链式编程 #include using namespace std; //对于友元函数重载运算符只适用于左操作数是系统变量的场景 //因为成员无法在系统变量中添加类成员函数,只能靠全局函数来实现 //链式编程的本质是:函数返回值当左值 class Point { public: //注意友元函数中,返回值不同,友元函数就会不同,跟函数重载有区别 friend o... 阅读全文

posted @ 2016-06-27 16:25 寒魔影 阅读(833) 评论(0) 推荐(0)

C++ 运算符重载二(一元运算符重载)

摘要: //一元运算符重载 #include using namespace std; class Point { public: Point(int x,int y){ this->x = x; this->y = y; } Point(Point &p){ this->x = p.x; this->y = p.... 阅读全文

posted @ 2016-06-27 11:32 寒魔影 阅读(1375) 评论(0) 推荐(0)

C++ 运算符重载一(二元运算符重载)

摘要: //二元运算符重载 #include using namespace std; class Point { public: Point(int x,int y){ this->x = x; this->y = y; } //为什么要使用友元函数呢 friend Point operator+(Point &p1, Point &p... 阅读全文

posted @ 2016-06-27 10:26 寒魔影 阅读(1413) 评论(0) 推荐(0)

导航