I made a post a while back asking how to call the overridden method. The answer that I got is that you cannot. One good argument given was that of polymorphism, that you are constructing the subclass, so it is the subclass' method (and not the superclass) that should be called. But when it comes to a hidden variable, it is different. If the method that uses the variable is in the superclass, even though that method is inherited, it is the superclass variable that is used.
Result: A.m1() i:10 B.m2() i:20 If I were to use the same argument used for overridden methods then the program should constantly use B's i variable. The program is constructing a B object, not A. But that is not what is happening here. Because of this behaviour, if I want to reuse A's m1(), but using my own variable, I cannot. I have to override m1() with the same set of codes.
...I want to reuse A's m1(), but using my own variable...
I think the TEMPLATE METHOD Pattern can be applied to your problem. A class implements an algorithm. The algorithm is broken down into primitive operations. A subclass implements the primitive operations. In your example, the primitive operation is merely to read a variable i. [ June 28, 2003: Message edited by: Marlene Miller ]