
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
188
|
Chapter 6: Inheritance
public function over ( ):Void {
}
}
class B extends A {
public function over ( ):Void {
super.over( );
}
}
Note the difference between using an inherited method versus calling an overridden
method via super. In the former case, the subclass does not define the method but
rather implicitly executes the method inherited from the superclass. In the latter
case, the subclass’s overriding method must use super to explicitly call the overrid-
den superclass method.
In the following code, we invoke the over( ) method on an instance of B. Without
looking at the class definitions we can’t tell that it invokes A.over( ) via super behind
the scenes. In fact, in a properly designed object-oriented application, the internal
implementation should be of no concern to the external code calling the class.
var bInstance:B = new B( );
bInstance.over( );
Member access from an overridden method is the same as from an inherited method,
as shown in Table 6-3. The following code shows you the syntactical difference
between overridden method access and inherited method access. Despite the differ-
ence in code, the Notes column in Table 6-3 pertains verbatim to member access
from overridden methods. See also the earlier sections “Overriding Properties” and
“Overriding Instance Methods.” ...