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
Imagine that your example worked.
Consider the following code:
A *a = some_function();
A::Inner inner = a->blah();
If the dynamic type of a
is B*, then a->blah()
calls a::B->blah()
, and returns a B::Inner
. This is then silently sliced into an instance of A::Inner
. In general, this (and any type of slicing) is not what you want. I find this to be a good restriction.