#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    14
    Rep Power
    0

    Member Function Pointer issues..


    I've been trying to get pass a member function as a pointer. I've been here.

    My code looks like this:
    Code:
    typedef HRESULT (some_class::* some_mfp (long*);
    some_mfp derp = HRESULT (some_class::*member_function)(long*);
    and my error is:
    error C2143: syntax error : missing ')' before '<tag>::*'
    error C2059: syntax error : ')'
    I know it's close, and from the looks of the stack overflow link it should be correct. Please help!


    Note: I do realize you're typically not supposed to do this (and it's explicitly mentioned in the C++ faq.) However, sometimes when you're knee-deep in ugly code you have to break out the big guns. Please give me the benefit of the doubt and help me with syntax.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    14
    Rep Power
    0
    Arg. Sorry, I fixed it. Looks like I was missing a "__stdcall" from my definition (I had had it in there earlier) and now it works.

    For completeness:
    Code:
    typedef HRESULT (__stdcall some_class::* some_mfp (long*);
    some_mfp derp = HRESULT (some_class::*member_function)(long*);
    I'll mention this was a COM class I'm hooking up to; hence the need for __stdcall. Glad I didn't waste anyone's time!

IMN logo majestic logo threadwatch logo seochat tools logo