Polymorphism of wxWindows

63q2o4i02 at sneakemail.com 63q2o4i02 at sneakemail.com
Sat Sep 2 18:38:55 PDT 2006



Vadim Zeitlin wrote:
> On 2 Sep 2006 13:50:43 -0700 63q2o4i02 at sneakemail.com wrote:
>
> > 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 it wasn't a virtual one. Polymorphism only works for virtual
> functions in C++.
>
> > 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?
>
>  Yes, this is normal behaviour. Use wxGetApp() to retrieve the app object
> of the "correct" type (and see also DECLARE_APP() macro).
>

Ok, thanks.  That's what I wound up doing anyway.  My C++ thinking is a
bit rusty since I've been infected with Python the last year or so.  I
wonder if the GetApp() function actually resolves to a real function
call or if the compiler is able to determine the vaue at compile time.
... interesting.

ms







More information about the wx-users mailing list