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

Jacques Tremblay (jackt@gel.ulaval.ca)
Fri, 1 Aug 1997 08:45:51 -0400 (EDT)

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/