Is there a way to prevent a class from being derived from twice using a static assert and type trait?

前端 未结 3 1913
北海茫月
北海茫月 2021-01-19 08:10

I realize this is a contrived example, but I want a compile check to prevent this...

class A {};
class B : public A {};
class C : public A {};

class D : pub         


        
3条回答
  •  难免孤独
    2021-01-19 08:54

    When I try to derive a class twice as you have here it does not even compile. (duplicate base type)

提交回复
热议问题