// all the codes below are working in Visual Studio 2012
// need to check on other compilers since the rules may different from VS
class VA
{
public:
VA(void) {}
~VA(void) {}
void setValue(int v) { value = v + 300; }
protected:
int value;
};
typedef void (VA::*PFUNC)(int);
PFUNC pfunc = &VA::setValue; // & is a must-have for function pointer to a class member function
VA va;
(va.*pfunc)(200); // * here is also a must-have
void (VA::*p_setvalue)(int) = &VA::setValue; // not use typedef
(va.*p_setvalue)(300);
int (*funcp)(int, int) = testFuncPointer; // for global function, both & and * are not necessary
int ret = funcp(1, 2);
// note:// all the codes below are working in Visual Studio 2012// need to check on other compilers since the rules may different from VS class VA { public: VA(void) {} ~VA(