Red*_*gCZ 3 c++ multiple-inheritance
我只是想知道下面的代码块是否在C++中完全有效:
class A
{
public:
virtual bool b() = 0;
};
class B
{
public:
virtual bool b() = 0;
};
class C: public A, public B
{
public:
virtual bool A::b()
{
return true;
}
virtual bool B::b()
{
return false;
}
};
Run Code Online (Sandbox Code Playgroud)
使用VS2008,它编译时没有任何错误,但是,在GCC(MinGW)3.4.5上,它给出了如下错误:
cannot declare member function `A::b' within `C'
Run Code Online (Sandbox Code Playgroud)
在实现虚拟方法的行上.我很好奇,如果这通常被认为是无效的,并且由C++标准禁用代码(并且在VS中因此可以通过某些MS非标准化魔法工作),或者只是GCC中的错误或不支持的语言功能.
| 归档时间: |
|
| 查看次数: |
475 次 |
| 最近记录: |