Calling pointers to class methods

I'm trying to call a pointer to a class method with the compiler spitting out: "term does not evaluate to a function"

This is basically what I'm trying to implement:

class Thing;
typedef long(Thing::*FUNC)(int, void**);

class Thing {
   Thing() { /*code & other junk */ }
    long someMethod(int n, void **ppv) { /* code */}
    void doIt(void {
       FUNC f = someMethod;    //This is legal..... (I'm actually using an array of pointers in my code....)

        /* more code */

        f(nSomeInt, &vpSomePointer);  //craps out here..... "term does not evaluate to a function"



this snippet is quite lacking but it shows what i mean. This works fine with a regular static function. Why not with an instance method?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You have to use

Thing* p = this;

p->f(nSomeInt, &vpSomePointer);  
chutney_manAuthor Commented:
That doesn't work ;-)
Try the following:
 (f)(nSomeInt, &vpSomePointer);
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

Just checked the places where I used contructs like that:

(p->f)(nSomeInt, &vpSomePointer);
The following should work:

       ((*this).*f)(nSomeInt, &vpSomePointer);
Both of the following syntax will work.

(this->*f)(nSomeInt, &vpSomePointer);

((*this).*f)(nSomeInt, &vpSomePointer);

The main thing is that you need to use the * charactor before the "f" function variable, and you have to put brackets around the entire function pointer syntax.
>>(this->*f)(nSomeInt, &vpSomePointer);

Not with VC6 :o)
>>Not with VC6 :o)

Yes, with VC6.  I tested it with VC6 before I posted.
Even though I have VC 7.1, I still do most of my testing on VC6.0 since I see it as the lowest denominator.
Here's a full example you can compile on VC6.0:

class Thing;
typedef long(Thing::*FUNC1)(int, void**);

class Thing {
   long someMethod_non_static(int n, void **ppv) { return 3;}

    void doIt(void) {
      FUNC1 f_non_static = someMethod_non_static;
       ((*this).*f_non_static)(3, NULL);
       (this->*f_non_static)(3, NULL);


int main(int argc, char* argv[])
      Thing MyThing;

Just out of curiousity, do you use, or are you using

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chutney_manAuthor Commented:
ahh thanks guys. (this->*f) did it......  and yes it does work in VC6  :)

Cripes, I should have thought of that too :P
No comment has been added lately, so it's time to clean up this question.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: Axter {http:#9609331}

Please leave any comments here within the next four days.

EE Cleanup Volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.