Re: How to call the subclass's method?
From: William Stacey [MVP] (staceywREMOVE_at_mvps.org)
Date: 04/21/04
- Next message: Steve Bishop: "Re: Cannot Find Column error"
- Previous message: Bjorn Abelli: "Re: How to call the subclass's method?"
- In reply to: Quentin Huo: "How to call the subclass's method?"
- Next in thread: Paul Qualls: "Re: How to call the subclass's method?"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 21 Apr 2004 16:49:14 -0400
If the method is unique to the subclass you may not want it virtual as other
subclasses may not need it. Have you tried to cast the object to the
subclass type like this:
mySubclass msc = (mySubclass)mc;
msc.methodOfSubclass();
-- William Stacey, MVP "Quentin Huo" <q.huo@manyworlds.com> wrote in message news:uCK7v#9JEHA.3436@tk2msftngp13.phx.gbl... > Hi, > > I created a class "myClass" and another class "mySubclass" which inherited > from "myClass". In the "mySubclass", there is a public method named > "methodOfSubclass(...)" which is not defined in "myClass". > > In a client program I tried to call the "methodOfSubclass(...)", like > > ...... > myClass mc; > mc = new mySubclass(); > mc.methodOfSubclass(...); > ...... > > but I got an error message when I tried to compile it: > > '...myClass' does not contain a definition for 'methodOfSubclass' > > What is the problem? Do I have to create a virtual method > "methodOfSubclass(...)" in "myClass" and override it in "mwSubclass"? Any > other solutions? > > Thanks > > Q. > > >
- Next message: Steve Bishop: "Re: Cannot Find Column error"
- Previous message: Bjorn Abelli: "Re: How to call the subclass's method?"
- In reply to: Quentin Huo: "How to call the subclass's method?"
- Next in thread: Paul Qualls: "Re: How to call the subclass's method?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|