[ODE] Moving ode test program into a class

skjold@cistron.nl skjold at cistron.nl
Sun Feb 16 12:17:02 2003


Oops, I accidentally sent this reply to Pete personally, instead of to the list... :P This is getting weird, hehehe...

-- >8 --------[ snip ]----- >8 -----

Hi Pete,

Sounds like you're not using a static class method. This functions roughly the same as in Java. You can't take the address of a non-static (instance) method, because it is bound to an instance of your class ("this"). But it should work fine if you assign a static method. The only problem then is that you can't reach your instance from there, unless you use another way for that (for example a static class member variable pointing to a singleton instance).

One more thing: All those function pointers are strictly a part of the drawstuff library, they are not part of ODE. You could also use ODE with another graphics library (or without any graphics, for that matter), they are separate things.

Does that help?

Greets,
Mark

> I'm quite new to C++ (but some with C & Java experience), and trying to 
> experiment with ODE.
> 
> I've tried moving some functions [eg void start()] into a new class called 
> Simulation to use as part of another program. There is a few lines that 
> stores pointers to some of the functions, and passes them to another 
> function within the physics library.
> 
> // setup pointers to drawstuff callback functions
> dsFunctions fn;
> fn.start = &start;
> fn.step = &simLoop;
> fn.command = &command;
> ...
> // run simulation
> dsSimulationLoop (argc,argv,352,288,&fn);
> 
> So in the class version I have tried to write:
> fn.start = &Simulation::start;
> fn.step = &Simulation::simLoop;
> fn.command = &Simulation::command;
> But I get the error "cannot convert `void (Simulation::*)()' to `void (*)()' 
> in assignment"
> 
> I also tried:
> fn.start = &(Simulation::start);
> fn.step = &(Simulation::simLoop);
> fn.command = &(Simulation::command);
> But this said: "taking address of bound pointer-to-member expression".
> 
> Could someone explain what I am doing wrong?
> 
> Thanks,
> 
> Pete.
> 
> _________________________________________________________________
> Surf together with new Shared Browsing 
> http://join.msn.com/?page=features/browse&pgmarket=en-gb&XAPID=74&DI=1059
> 
> _______________________________________________
> ODE mailing list
> ODE@q12.org
> http://q12.org/mailman/listinfo/ode
>