Slimelite BBS

pointers to member funct

Back to EMULATE

From Sean Palmer · 1996-04-10 22:55 · #73585 in EMULATE

MS>bs( ((TBlackHoleOrbitsWindow *)MainWindow)->pfX,
MS>    NV, 
MS>    &TBlackHoleOrbitsWindow::Derivs);
MS>The error output is: Compiling SOURCE\BHORBITS.CPP:
MS>Error SOURCE\BHORBITS.CPP 70: Cannot convert
MS>'void(TBlackHoleOrbitsWindow::*)(float,float *,float *)' to 'void
MS>(*)(float,float *,float *)'
MS>And I can live with these, as long as it is possible to make a appropia
MS>convertion. I can't figure out how to accomplish that. Any ideas? 
Make that method a static method. The typecast should work then. You'll 
have to figure out some other way to regain access to the object's dynamic 
data. Probably have to use a global or a static data member which points to 
the 'current' object or some other nasty kludge.

Problem is that a member function that is not static also takes a 
'hidden' parameter:  the 'this' pointer.  The DLL would not provide this 
'hidden' pointer and things would get confused real fast. This is why 
type-checking is a good thing. In this case what you're trying to do 
looks like it will work, but it won't... stuff is going on that you're 
not aware of. The compiler is saving you from certain doom. 8)

But a static method isn't linked to any particular instance of the class, 
so is compatible with a normal (global scope) function.  

Unfortunately there's no easy way to associate the calling of your function 
with the instance whose data you're interested in (the 
TBlackHoleOrbitsWindow).

---
 * WR 1.32 # 380 * Man's best possession is a sympathetic wife.
 * Origin: deltaComm Online (919) 481-9399 (1:151/107)