# 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 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).

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628354
• Total Posts
2982243

• 10
• 9
• 11
• 24
• 11