Advertisement

Setting Up Class Function Pointers

Started by May 10, 2000 04:04 PM
1 comment, last by Marty 24 years, 7 months ago
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:
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))();} 
Advertisement
SiCrane, you are a star !!!

Rgds,

Marty.

This topic is closed to new replies.

Advertisement