Sign in to follow this  
maya18222

quick question on class function callback

Recommended Posts

Hi, A while back i stumbled across a link here to a web page showing an example of how to create a class function that is a callback, through the use of a staticProc and also the proper proc. But i can seem to find this link, does anyone have any idea the link im referring to? if you could link it here, that would be great, thanks. And also, am i of the correct understanding, that i could only use method2, of just using a static Callback method, only if all the parameters i which to use are static too?

Share this post


Link to post
Share on other sites
The basic idea is as follows:

class obj 
{
public: void callback();
};

void callback()
{
obj &o = /* obtain the object */
o.callback();
}


Obviously, you need to obtain the object somehow. This can be done either by having the other function provide the object as an argument to the callback (many C interfaces pass a void* argument to the callback) or by storing the callback data in a global location from where you can get it (such as SetLongWndPointer for the Win32 API).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this