Get pointer to member function from within member function in C++
Posted
by
Eli
on Stack Overflow
See other posts from Stack Overflow
or by Eli
Published on 2010-12-26T07:49:06Z
Indexed on
2010/12/26
7:53 UTC
Read the original article
Hit count: 291
c++
Currently in the program I am attempting to write I need to be able to get a pointer to a member function within a member function of the same class. The pointer needs to be passed to a function as a void (*)(). Example:
//CallFunc takes a void (*)() argument
I'm trying to do this in GCC 4.0.1. Also, the member function being called can't be static because it references non-static variables in the class that it is part of.
class testClass {
public:
void aFunc2;
void aFunc1;
}
void testClass:aFunc2(){
callFunc(this.*aFunc1); // How should this be done?
}
void testClass:aFunc1(){
int someVariable = 1;
}
© Stack Overflow or respective owner