Sponsored Link •
|
Advertisement
|
Advertisement
|
This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.
Message:
I thought that when a class extends a base class it can upcast to the base class type. So WindX would be included as a type InstrumentX. Since it doesnt work without an explicit cast, does this mean that overloading does not work with inheritance? > The problem is in the tune method defined in WindError. The tune method takes a parameter of type InstrumentX. Because there is no play method on InstrumentX that takes a NoteX, an error is thrown. An explicit cast is needed on the incoming InstrumentX object to cast it to a WindX object. Then you can call the WindX's play method.
Replies:
|
Sponsored Links
|