Forum

Results 1 to 2 of 2
  1. #1
    Join Date
    April 2008
    Location
    Germany
    Posts
    2

    Question Problem using Callbacks with C++ (member function)

    Can anyone point me into the right direction to use member functions for the callbacks when using C++?

    You can pass any non-member function without problems like that:
    Code:
    struct ClientUIFunctions funcs;
    
    /* Initialize all callbacks with NULL */
    memset(&funcs, 0, sizeof(struct ClientUIFunctions));
    funcs.onConnectStatusChangeEvent        = onConnectStatusChangeEvent;
    But I need a way to use something like this:
    Code:
    funcs.onConnectStatusChangeEvent = &MyClass::onConnectStatusChangeEvent;
    Please give some advise for one of the Events, so that I can start adding the others.

    Thanks in advance!

  2. #2
    Join Date
    December 2009
    Location
    Germany
    Posts
    7
    I assume you want to use non static functions?

    If that's the case, that wouldn't work out, member functions are __thiscall, besides classes don't work like that, you cannot get the member function of a single instance, all instances share the same member functions.

    You can either create a global instance class and call the members functions in the specified callbacks, or create static functions that will iterate through all instances of that class, I guess that last method is the cleaner one.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Rejected] [Suggestion] to add flexibility to member add/member remove permissions.
    By Morthawt in forum Suggestions and Feedback
    Replies: 1
    Last Post: September 18th, 2014, 09:38 AM
  2. [Forwarded] Plugin Audio callbacks not included in recording
    By Philosound in forum Bug Reports [EN/DE]
    Replies: 0
    Last Post: July 26th, 2013, 12:42 PM
  3. [Solved] Use SDK 3 callbacks in C++
    By Booster87 in forum General Questions
    Replies: 1
    Last Post: April 14th, 2010, 05:23 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •