> If they > really need to access the overridden method in the Base Class, they should > cast the derived class as the base type and then call the method.
You can't do this. The cast will happily work (assuming you're using an OO language with casts, such as Java or C#), but the polymorphic nature of the language will still call the subtype's method. Here's a Java example: String s = "my String"; System.out.println(s.toString()); System.out.println( ((Object) s).toString()); In both cases, the String class's toString method will be called. It is IMPOSSIBLE to call a supertype's method on an object of a subtype that overrides that method, except from within the subtype. This is Good Thing, every way you look at it. cheers, barneyb On Wed, 27 Oct 2004 20:30:50 -0400, Roland Collins <[EMAIL PROTECTED]> wrote: > I think you may be modeling the relationship wrong. To use your Vehicle > example... > > Vehicle would be a Base Class - it wouldn't have a "vehicle type" property. > Instead, you would have subclasses extend it. The hierarchy could look like > this: > > Vehicle > -----.Location > -----.NumberOfWheels > > MotorCycle Extends Vehicle > -----.DriveType > > Truck Extends Vehicle > -----.BedLength > > Car Extends Vehicle > -----.SomeSillyProperty > > By doing this, instances MotorCycle, Truck, and Car all have access to all > of Vehicle's methods without using the super keyword. If you're overriding > a method in the derived class, then that is an implementation decision and > an interface that should not be circumvented by your end user. If they > really need to access the overridden method in the Base Class, they should > cast the derived class as the base type and then call the method. > > My .02 > -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/blog/ I currently have 0 GMail invites for the taking ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
