C++ examples for Class:Member Function
Taking the Address of a Member Function
#include <iostream> #include <string> using namespace std; class Util/*from www. ja v a 2s. c o m*/ { public: int WhichUtil; int Chew(string name) { cout << WhichUtil << endl; cout << name << endl; return WhichUtil; } }; int main() { typedef int (Util::*GobMember)(string); GobMember func = &Util::Chew; Util inst; inst.WhichUtil = 10; Util another; another.WhichUtil = 20; (inst.*func)("test"); (another.*func)("hi"); return 0; }