Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling pointers to class methods

Status
Not open for further replies.

xGrob

Programmer
Jun 6, 2001
36
CA
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?
 
I believe you have to have an object of type Thing to call it on. Perhaps using it from inside the class confuses the compiler and it can't figure out you mean to use it on "this".

Maybe explicitly say:

Code:
this->*f( anInt, &aVP );
 
Ahh found out on "Experts Exchange"

(this->*f)(nSomeInt, &vpSomePointer)... you were close though chipper
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top