Virtual Inheritance: Error: no unique final overrider

后端 未结 2 1396
情歌与酒
情歌与酒 2020-12-05 07:54

I know virtual inheritance is covered here before and before asking this question, I went through the detail of the virtual inheritance and went through the details of a sim

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-05 08:15

    The most-derived class has to provide an implementation of the virtual functions in the virtual base class - otherwise how would it provide that base class interface, given the intermediate classes (i.e. your der1 and der2) provide two alternatives already - which one should it call? You have to disambiguate the situation (i.e. with der3::fun()).

    Sure you're not actually calling der3::fun() as you're explicitly requesting base::fun(), but that doesn't mean the rules don't apply, any more than thinking you could instantiate an abstract class if you don't try to call the pure-virtual functions.... The program is ill-formed until the code ties off these loose ends.

提交回复
热议问题