
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Overriding Methods and Properties
|
189
Here, we invoke the inherited method, methOfA( ), which in turn invokes
otherMethOfA( ):
// ==== Inherited method access ====
class A {
public function methOfA( ):Void {
// Executes otherMethOfA( )
otherMethOfA( );
}
public function otherMethOfA( ):Void {
}
}
class B extends A {
}
// Usage:
var bInstance:B = new B( );
bInstance.methOfA( );
The complexity of overridden member access in Tables 6-3 and 6-4 is, in itself, a
warning to the developer not to override methods lightly.
Always use caution when overriding members. Excessive overriding
can lead to unmanageable, confusing source code. If you can’t easily
predict the runtime results of your code’s overridden member access,
you should simplify your code.
Now that we’ve learned how member access works in inherited and overridden
instance methods, let’s see how it works in inherited and overridden class methods.
Member Access from Inherited
and Overridden Class Methods
Compared to instance method member access, member access from class methods is
quite restricted. A class method cannot use the keyword super to refer to members of
a superclass. Neither can it refer to instance properties or instance methods.
A class method, whether overridden or not, is allowed to access other
class methods and class properties ...