我要做的是开发两个不同的基类,这些基类不应该在一个派生类中一起继承.有什么办法可以在编译时强制执行吗?
class Base1 {};
class Base2 {};
class Derived1 : public Base1 {} // OK!
class Derived2 : public Base2, public Other {} // OK!
class Derived3 : public Base1, Base2 {} // Can I force the compiler to complain?
Derived1 d1; // OK!
Derived2 d2; // OK!
Derived3 d3; // Or can I force the compiler to complain here?
Run Code Online (Sandbox Code Playgroud)
我知道文档是一个好主意,只是想知道它是否可行.