class CInsLibrary
{
public:
CInsLibrary(){;}
virtual ~CInsLibrary(){;}
public:
void Func(int i){;}
};
typedef void (CInsLibrary::*PFUNC)(int );
//main.cpp
PFUNC pp = CInsLibrary::Func; //1)
CInsLibrary* pLib = new CInsLibrary;
PFUNC ppp = (pLib->Func); //2)
ASSERT(pp == ppp); //caution!!
上面的代码在VC6中编译的很好,但是在VS2005中,
1)必须改为
PFUNC pp = &CInsLibrary::Func; 否则就是Compiler Error C3867
2)中的这种写法,VS2005已经不支持了。因为的确,指向成员函数的指针,更合理的写法是class::foo而不是object.foo