error #547: nonstandard form for taking the address of a member function

Hi,

I'm new to c++ and have been learning on this site. I'm trying to pass the address to a member function into a function and having trouble in c++. This is trivial in c because you just put the name of a stand-alone function in without the parenthesis. The key difference now is that the function is inside of a class. It might not be possible, but if it is, please let me know how.

Here's and example:

cmainwindow.cpp(98): error #547: nonstandard form for taking the address of a member function
glutReshapeFunc((void *)(reshape));

if reshape is a function that stands alone in c, it's ok, but if it's the exact same function inside a class, I can't seem to reference it, even when inside that class.

Any suggestions?
The syntax is pretty ugly. I myself can never remember it.
1
2
3
4
5
6
7
8
9
10
struct A{
	returnType f(type1,type2);
};

typedef returnType(A::*A_methodPointer)(type1,type2);

void f(A_methodPointer pointer){
	A a;
	(a.*pointer)(b,c); //IIRC, the parentheses are mandatory.
}
Topic archived. No new replies allowed.