Functions (Section 1.4, Chapter 3) are convenient tools to abstract behaviour and computation. E.g. once the function sqrt (double) has been properly defined, one does not need to remember how it computes its result in order to use it. Moreover, if one prefers an alternative algorithm for the computation of sqrt (double), it is easy to change just the function body of the definition, without disturbing the rest of the program’s code. One can say that the computation of sqrt (double) is encapsulated inside its definition which can be changed at will, as long as the specification of the function, i.e. its interface, remains the same.
KeywordsClass Object Class Definition Rational Class Conversion Function Assignment Operator
Unable to display preview. Download preview PDF.