T
Tony Johansson
Hello!
Is this text really correct ?
Sometimes you may want to create your own implementation of a method that
exists in a base class. The DerivedClass class does this by declaring its
own print() method. The DerivedClass print() method hides the BaseClass
print() method. The effect is the DerivedClass print() method will not be
called, unless we do something special to make sure it is called.
Notice the new modifier on the DerivedClass class print() method. This
enables this method to hide the BaseClass class's print() method and
explicitly states your intention that you don't want polymorphism to occur.
Without the new modifier, the compiler will produce a warning to draw your
attention to this. See later for a discussion of polymorphism.
I mean I don't quite understand when the text say The DerivedClass print()
method hides the BaseClass print() method ?
Can somebody explain that .
//Tony
Is this text really correct ?
Sometimes you may want to create your own implementation of a method that
exists in a base class. The DerivedClass class does this by declaring its
own print() method. The DerivedClass print() method hides the BaseClass
print() method. The effect is the DerivedClass print() method will not be
called, unless we do something special to make sure it is called.
Notice the new modifier on the DerivedClass class print() method. This
enables this method to hide the BaseClass class's print() method and
explicitly states your intention that you don't want polymorphism to occur.
Without the new modifier, the compiler will produce a warning to draw your
attention to this. See later for a discussion of polymorphism.
I mean I don't quite understand when the text say The DerivedClass print()
method hides the BaseClass print() method ?
Can somebody explain that .
//Tony