Declare a pure virtual function in both bases that have a different return type:
class B1 {
virtual void a() = 0;
};
class B2 {
virtual int a() = 0; // note the different return type
};
It's impossible to inherit from both.
class D : public B1, public B2 {
public:
// virtual void a() {} // can't implement void a() when int a() is declared and vice versa
virtual int a() {}
};
int main(void) {
D d; // produces C2555 error
return 0;
}
This error is produced:
- error C2555: 'D::a': overriding virtual function return type differs and is not covariant from 'B1::a'
- see declaration of 'B1::a'