C++ operator overloading
An operator is a symbol that tells the complier to perform specifc mathematical or logical manipulations.
C++ allows u to specify more than one definition for an operator in the same scope, which is called operator overloading.
almost all operators can be overloaded in c++; except below:
1. socpe operator ::
2. sizeof
3. member selector .
4. member pointer selector *
5. ternary operator ?:
我们期待C3 直接 变成7,9; 但是实际上编译的时候会报错, 因为对于class的对象而言还没有定义+这样的操作
如何定义呢:
这个例子中real 是C1 的;c.real是C2的;
返回一个临时的赋值给C3