|
发表于 2013-3-18 21:39:19
|
显示全部楼层
class CTest
{
public:
typedef int (*CommandFunc)(int a);
CTest()
{
CommandFunc p;
p = &CTest::Test;
cout<<p(10)<<endl; // 就是这里啦.. 这里会编译出错,说什么"项不会计算为接受 1 个参数的函数"
}
static int Test(int a)
{
return a + 1;
}
};
把成员函数写成静态的,可以直接p(10),不过typedef也要变下,非静态的成员函数貌似只能通过你提的那种方法
|
|