Where in the standard is forwarding to a base class required in these situations?
Posted
by pgast
on Stack Overflow
See other posts from Stack Overflow
or by pgast
Published on 2010-05-29T02:21:02Z
Indexed on
2010/05/29
2:22 UTC
Read the original article
Hit count: 245
Maybe even better is: Why does the standard require forwarding to a base class in these situations? (yeah yeah yeah - Why? - Because.)
class B1 {
public:
virtual void f()=0;
};
class B2 {
public:
virtual void f(){}
};
class D : public B1,public B2{
};
class D2 : public B1,public B2{
public:
using B2::f;
};
class D3 : public B1,public B2{
public:
void f(){
B2::f();
}
};
D d;
D2 d2;
D3 d3;
EDG gives:
sourceFile.cpp
sourceFile.cpp(24) : error C2259: 'D' : cannot instantiate abstract class
due to following members:
'void B1::f(void)' : is abstract
sourceFile.cpp(6) : see declaration of 'B1::f'
sourceFile.cpp(25) : error C2259: 'D2' : cannot instantiate abstract class
due to following members:
'void B1::f(void)' : is abstract
sourceFile.cpp(6) : see declaration of 'B
and similarly for the MS compiler.
I might buy the first case,D. But in D2 - f is unambiguously defined by the using declaration, why is that not enough for the compiler to be required to fill out the vtable?
Where in the standard is this situation defined?
© Stack Overflow or respective owner