#include <iostream> using namespace std; class Test { public : void print() { cout << "abcd" << endl;; } double test() { cout << "double" << endl; return 2; } }; typedef void (Test::* SEL_SHEDULE)();//定义函数指针类型 void(Test::*p)() #define f(print) (SEL_SHEDULE)(&print);//把括号类的转化为SEL_SHEDULE类型 void main() { Test a; void(Test::*ppp)() = &Test::print; (a.*ppp)(); SEL_SHEDULE p; p = &(Test::print); (a.*p)(); SEL_SHEDULE pp = f(Test::print); (a.*pp)(); SEL_SHEDULE pppp = f(Test::test); (a.*pppp)(); //这里不能使用cout << (a.*pppp)() 因为已经转化成void类型 double (Test::*b)() = &Test::test; cout << (a.*b)() << endl; system("pause"); }