Default constructor and virtual inheritance

后端 未结 4 1852
无人共我
无人共我 2020-12-11 00:50

Is possible to have virtual inheritance for class not providing default constructor?

The present diamond diagram (the simplest one with the only change of no default

4条回答
  •  被撕碎了的回忆
    2020-12-11 01:24

    The Dr. Dobbs article Multiple Inheritance Considered Useful explains various ways of dealing with this. The recommendation is basically to provide default constructors and init() methods. It adds more work for B and C but prevents D from having to know about A.

提交回复
热议问题