Yurttas/PL/OOL/Cplusplus/F/03/02/00/04.html
programming languages - design principles, implementation constructs
c++
- abstraction mechanisms: classes and operator overloading
- operator overloading
- basic rules - binary and unary operators - example
class A { // members (with implicit first argument: this) : A* operator& (); // prefix unary & (address of) A operator& (A); // binary & (and) A operator++ (int); // postfix increment A operator& (A,A); // error: ternary A operator/ (); // error: unary / // global functions (often friends) : friend A operator- (A); // unary minus friend A operator- (A,A); // binary minus friend A operator-- (A&,int); // postfix decrement friend A operator- (); // error: no operand friend A operator- (A,A,A); // error: ternary friend A operator% (A); // error: unary % };
- basic rules - binary and unary operators - example
- operator overloading
1 | basic facilities << 3 >> class derivation | 5 | 6 | 7 | 8