Member Function Callback

From: Chris Morley (g18c_at_nospam.hotmail.com)
Date: 09/14/04


Date: Tue, 14 Sep 2004 19:27:20 GMT

Hi, I have always done my C++ class callbacks with the age old 'using this
pointer in parameter of the class's static callback function' and
typecasting it to get the specific instance.

However I'm left wondering are there any better ways of doing this?

Just before I left work today I came across functors, which look promising.
I will have a proper look tomorrow, but I have a few questions in the mean
time.

Is it possible to use functor classes with standard, precompiled, c style
callback code, passing them in as pointers? Or do I need to pass a pointer
to the base class of the translating class and have to recompile code in
order for the derefencing to work?

I'm going to have a look online now for some examples whereby callbacks are
made compile time safe, in the meantime (and indeed if I cant find any), can
anyone recommend some good examples?

Many thanks in advance,

Chris



Relevant Pages

  • Re: Callbacks and FFI Techniques
    ... Part of it in C and the other part in Scheme. ... function that I can use to set all these callbacks to the right values ... So you either have to declare your pointer variable as a type ... int func1; ...
    (comp.lang.c)
  • Re: How to implement callback?
    ... imagine that there's an event that indicates that all process callbacks ... and pass the pointer to a callback function. ... certerial hook manager. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: How to implement callback?
    ... imagine that there's an event that indicates that all process callbacks ... and pass the pointer to a callback function. ... certerial hook manager. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: How to set a mouse / keyboard hook in windows CE device using C# code ?
    ... plan to accomplish if you get it working... ... Paul T. ... > Since SetWindowsHookEx@coredll accept pointer to a function and callbacks ...
    (microsoft.public.dotnet.framework.compactframework)