上一页 1 2 3 4 5 6 7 8 9 ··· 24 下一页
摘要: 使用示例 阅读全文
posted @ 2019-12-01 15:02 路边的十元钱硬币 阅读(1182) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> // overloading "operator + " // 要考虑加法的形式 // a+1 // a+a // 1+a ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(const int w, const int 阅读全文
posted @ 2019-12-01 14:33 路边的十元钱硬币 阅读(281) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> // overloading "operator () " outside class ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(const int w, const int h) : width(w), hei 阅读全文
posted @ 2019-12-01 14:16 路边的十元钱硬币 阅读(232) 评论(0) 推荐(0) 编辑
摘要: #include // overloading "operator [] " inside class ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(const int w, const int h) : width(w), height... 阅读全文
posted @ 2019-12-01 12:51 路边的十元钱硬币 阅读(209) 评论(0) 推荐(0) 编辑
摘要: ++i,应该是先自加一,返回自身(已经加1之后的自身); i++,应该是先拷贝自身,再自加一,返回自身的拷贝(自己已经加1,但是拷贝没有)。 阅读全文
posted @ 2019-12-01 12:43 路边的十元钱硬币 阅读(263) 评论(0) 推荐(0) 编辑
摘要: ++i,应该是先自加一,返回自身(已经加1之后的自身); i++,应该是先拷贝自身,再自加一,返回自身的拷贝(自己已经加1,但是拷贝没有)。 阅读全文
posted @ 2019-12-01 11:32 路边的十元钱硬币 阅读(653) 评论(0) 推荐(0) 编辑
摘要: #include // overloading "operator << " outside class // << 应该定义在类之外。 ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(int w, int h) : width(w), h... 阅读全文
posted @ 2019-12-01 10:22 路边的十元钱硬币 阅读(383) 评论(0) 推荐(0) 编辑
摘要: #include // overloading "operator = " outside class // 是二元操作符 ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(int w, int h) : width(w), height(... 阅读全文
posted @ 2019-12-01 10:01 路边的十元钱硬币 阅读(3940) 评论(0) 推荐(0) 编辑
摘要: #include // overloading "operator = " inside class // = 是一元操作符。不写,编译器会提供 默认 拷贝赋值函数。可以通过显式“=delete”来禁用默认。对于复杂class的默认=可能会造成问题,请特别注意。 ////////////////////////////////////////////////////////// clas... 阅读全文
posted @ 2019-12-01 09:44 路边的十元钱硬币 阅读(497) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> // overloading "operator == " outside class // == 是二元操作符 ////////////////////////////////////////////////////////// class Rectangle { public: Rectangle(int w, int h) : width(w), he 阅读全文
posted @ 2019-12-01 09:29 路边的十元钱硬币 阅读(320) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 24 下一页