看下面代码:vc6和vs.net2003下编译器输出如下结果
e:/我的控件/win32test/win32test/win32test.cpp(33) : error C2259: “C” : 不能实例化抽象类
由于下列成员:
“void A::sub::fun(void)” : 未定义纯虚函数
e:/我的控件/win32test/win32test/win32test.cpp(11) : 参见“A::sub::fun”的声明
编译器把B::sub看成了A::sub!DevC++下编译通过!汗一个!
#include "stdafx.h"
class A
{
public:
class sub
{
public:
virtual void fun() = 0;
};
};
class B : public A::sub
{
public:
class sub
{
public:
virtual void func(int a) = 0;
};
void fun(){}
};
class C : public B::sub
{
public:
virtual void func(int a){int xx = 0;}
};
int _tmain(int argc, _TCHAR* argv[])
{
C c;
system("PAUSE");
return 0;
}