VS2005编译器的一点改进 之 函数指针

类别:编程语言 点击:0 评论:0 推荐:

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

本文地址:http://com.8s8s.com/it/it21988.htm