Re: XForms: c++ : Works - but - corrupted type variables ?

Matthew Flax (flatmax@cse.unsw.EDU.AU)
Mon, 4 Aug 1997 00:11:39 +1000 (EST)

To subscribers of the xforms list from Matthew Flax <flatmax@cse.unsw.EDU.AU> :

Yep - that makes sense and works - it actually outlines this in the
README, however it didn't click !
thanks
Matt

On Fri, 1 Aug 1997, Jacques Tremblay wrote:

> To subscribers of the xforms list from Jacques Tremblay <jackt@gel.ulaval.ca> :
>
> Hi,
>
> I think your problem is due to the fact that the "this" pointer is
> stored in the form's structure from the baseClass object. Thus it is
> a pointer to the base class object. When you retrieve it, you
> cast it with an explicit cast to be of type callbackClass. What you
> should do to solve this problem is to store the "this" pointer to the
> most specific class (in that case the callbackClass) into the form's
> structure and use a the virtual function call mechanism to call
> the right callback in the specific class. I give you an example:
>
> in the base class:
>
> a static callBack called from the xforms library retrieves the
> "this" pointer that was stored by the callback class in its
> constructor. Then, it call a virtual function on this "this"
> pointer.
>
> in the callback class:
>
> The constructor stores the "this" pointer in the form's structure.
>
> An overload of the virtual function is declared in the callback
> class.
>
> I hope this mat help.
>
> JT
>
> P.S. When you use virtual functions in a class, don't forget to
> declare the destructor to be virtual too.
>
> _________________________________________________
> To unsubscribe, send the message "unsubscribe" to
> xforms-request@bob.usuf2.usuhs.mil or see
> http://bob.usuf2.usuhs.mil/mailserv/xforms.html
> Xforms Home Page: http://bragg.phys.uwm.edu/xforms
> List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/
>

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/