Yurttas/PL/OOL/Cplusplus/F/03/02/00/04.html

From ZCubes Wiki
Jump to navigation Jump to search
programming languages - design principles, implementation constructs
c++

  1. abstraction mechanisms: classes and operator overloading
    1. operator overloading
      1. 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 % };

<< | >>


1 | basic facilities << 3 >> class derivation | 5 | 6 | 7 | 8