overriding virtual function return type differs and is not covariant

后端 未结 6 1720
后悔当初
后悔当初 2020-12-17 23:36

Ah, SO came back just in time.

I am getting a strange error:

 \'B::blah\': overriding virtual function return type differs and is not covariant from          


        
6条回答
  •  南笙
    南笙 (楼主)
    2020-12-18 00:03

    The blah method have to return A::Inner in all cases -- if you think of the reason it is quite simple. A instance of B could easily be case to the base class A. Now if anybody calls blah on A (the base class which object should it return? Inner2 or Inner?

提交回复
热议问题