2.普通函数指向非静态成员函数 pTestFunc=foo.testFunc2; 编译器报错,提示不匹配 error: argument of type ‘void (Foo::)(int)’ does not match ‘void (*)(int)’
pTestFunc=&foo.testFunc2; 编译器报错,提示不匹配 error: ISO C++ forbids taking the address of a bound member function to form a pointer to member function. Say ‘&Foo::testFunc’ error: cannot convert ‘void (Foo::*)(int)’ to ‘void (*)(int)’ in assignment
pTestFunc=Foo::testFunc2; 编译器报错 error: invalid use of non-static member function ‘void Foo::testFunc(int)’
pTestFunc=&Foo::testFunc2; 编译器报错 error: cannot convert ‘void (Foo::*)(int)’ to ‘void (*)(int)’ in assignment
5. 类内部的 函数指针 指向成员函数 (类似于第2条) foo.pTestFunc5=foo.testFunc5; 编译器报错 test5.cpp:125: error: argument of type ‘void (Foo::)(int)’ does not match ‘void (*)(int)’
foo.pTestFunc5=&foo.testFunc5; 编译器报错 test5.cpp:123: error: ISO C++ forbids taking the address of a bound member function to form a pointer to member function. Say ‘&Foo::testFunc’ test5.cpp:123: error: cannot convert ‘void (Foo::*)(int)’ to ‘void (*)(int)’ in assignment