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

From ZCubes Wiki
Revision as of 22:05, 6 November 2013 by MassBot1 (talk | contribs) (Created page with "<div class="divone"><span class="h4"> Dr.Salih Yurttas - [mailto:yurttas@zcubes.com yurttas@zcubes.com] </span></div><div class="divone"><span class="h3"> programming langua...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Dr.Salih Yurttas - yurttas@zcubes.com
programming languages - design principles, implementation constructs
c++

  1. abstraction mechanisms: classes and operator overloading
    1. class/object construction - operator overloading
      1. binary and unary operators -
        • An operator function intended to accept a basic type as its first operand cannot be a member function.
        • For example, consider adding a complex variable aa to the integer 2; aa+2 can, with a suitably declared member function, be interpreted as aa.operator+(2), but 2+aa cannot because there is no class int for which to define + to mean 2.operator+(aa).
        • Even if there were, two different member functions would be needed to cope with 2+aa and aa+2. Because the compiler does not know the meaning of a user-defined +, it cannot assume that it is commutative and interpret 2+aa as aa+2. This example is trivially handled by using nonmember functions. << |

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