Here is an example of how you can use a pointer-to-function-member :
class A_t {
public:
void func(int);
void func2(int);
void func3(int);
void func4(int);
...
};
typedef void (A_t::*fnPtr)(int);
int process(A_t& o, fnPtr p, int x)
{
return ((o).*(p))(x);
}
int main()
{
fnPtr p = &A_t::func;
A_t a;
process( a, p, 1 );
...
}
In the main function you can use the func
member function as well as func2
, func3
or func4
.