|
||||||||||||||||||||||||||||||||||||||||||||
|
Don't get overiding and overloading confused. You can think of overloading as expanding the versions of a method along the horizontal axis. For example, here we show class A with several overloaded versions of the do() method:
We display the various versions of do() in columns on the horizontal axis. Below we show two subclasses of class A. Inheritance allows subclasses to override some or all of these versions of do() and also overload new ones. We show the methods of the base class and subclasses vertically below the base class. Here class B extends class A and overrides three of the do() methods. Class C extends class B and overrides the do(int i) method in class B:
Here the quotation mark " indicates that the code of the inherited method above it is used. Where a class method signature is written, the method overrides the inherited version. The base class A overloads the do() function with four different variations. Class B is a subclass of A and inherits its four methods but overrides two of them and overloads with a new one of its own. Class C is a subclass of B and inherits two do() methods from class A and two from class B. It overrides one method from class B. Latest update: Oct. 24, 2004
|
|
||||||||||||||||||||||||||||||||||||||||||
|