Setting Up Class Function Pointers
Rookie in need of help here.
How do I set up a pointer to a class function in C++?
e.g. Say I have a directdraw wrapper class called ''ddraw'', which has two blit functions, ''bltfullscreen()'' for a fullscreen mode blit, and ''bltwindow()'' for a windowed mode blit. How do I then setup a function pointer ddraw->blt() which calls the relevant function. By setup, I mean how do I define, and how to I assign the pointer variable?
Thanks,
Marty.
Ok let''s say this is your class:
Then blt should be a function pointer that can be assigned either bltfullscreen or bltwindow.
To use it:
class ddraw { public: void bltfullscreen(void); void bltwindow(void); void (ddraw::*blt)(void);};
Then blt should be a function pointer that can be assigned either bltfullscreen or bltwindow.
To use it:
int main() { ddraw * d = new ddraw(); d->blt = ddraw::bltfullscreen; (d->*(d->blt))();}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement