Operator overloading
Operator overloading
redefine the operations of operators
+ * / << >> ( ) [ ] …, 參考p. 286
eg. Complex number
Complex A, B, C;
C = A.add(B); // use member function add
C = A + B; // overload the operator +
格式: (function prototype)
Complex operator+(Complex&);
|
|