Polymorphism of wxWindows

ribrahim at sg.imshealth.com ribrahim at sg.imshealth.com
Sat Sep 2 20:42:42 PDT 2006


Hi,
Polymorphism - the wxApp pointer (assigned to a derived class instance
ptr MyApp) can only access members defined in the base class (wxApp); if
it's a virtual function, the function defined in it's derived class will
be executed. But if you defined extra functions in the derived class,
the base class pointer will not be able to access it. Beware also that
if you were to delete the wxApp pointer which is pointing to the MyApp;
only wxApp destructor will be deleted. The destructor in MyApp will not
be executed unless it's defined as virtual.

regards,
Radzi.

<63q2o4i02 at sneakemail.com> wrote in message
news:<1157230243.725278.199010 at e3g2000cwe.googlegroups.com>...
> 
> Hi, I was trying to access a member function of a wxPanel by using a
> wxWindow* pointer that had been assigned to a wxPanel.  I don't
> remember the name of the function, but the compiler complained that
the
> function was not a member of wxWindow.  I thought this was a perfect
> example of where polymorphism should work, but it didn't.  I had to
> make a pointer to wxPanel instead, and then it worked.
> 
> Same thing for MyApp derived from wxApp... I tried accessing a member
> variable of MyApp with a wxApp* pointer that had been assigned to
> MyApp, and the compiler didn't like it.
> 
> Is this normal behavior or am I doing something wrong?
> 
> wxMSW 2.7.0-1, MSVC++ Express, WinXP-SP2
> 
> (Sorry, I don't have example code.  I'm at home now and this is a work
> project).
> 
> ms.
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
> 
> 




More information about the wx-users mailing list