![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
运算符重载
一顿操作猛如虎,啥也不是!
时间,是让人猝不及防的东西,晴时有风阴有时雨。岁月是一场有去无回的旅行,好的坏的都是风景
展开
-
运算符重载--函数返回值
举例 #include using namespace std; class Test { public: Test(int a = 0) {cout Test(Test &temp){cout this class name: "name.c_str() ~Test(){cout friend Test operator + (转载 2015-12-14 10:52:39 · 3936 阅读 · 0 评论 -
运算符重载函数
我在网上搜到了两个资料,在程序中也都试验过了,有些疑惑。 复数相加: 第一种。 Complex operator+(Complex com1,Complex com2)//运算符重载函数 { return Complex(com1.real+com2.real,com1.imag+com2.imag); } 第二种: Complex Complex::operator+(Complex &c2)原创 2015-12-14 11:04:09 · 524 阅读 · 0 评论 -
重载运算符不能对指针单独操作
因为系统已经定义了两个指针的运算,所以你不能改变它 比如两个同类型的指针相加,就是指针的指相加,你是不能改变这个行为的 #include iostream> using namespace std; class Test{ int val; public: Test():val(0){} Test(转载 2015-12-14 11:16:34 · 1871 阅读 · 0 评论