I can't see ambiguity there. Have you transcribed the example correctly? Quoting C++11, [expr.dynamic.cast]
§8 (using dynamic_cast<C*>(v)
):
... if
v
points (refers) to a public base class subobject of the most derived object, and the type of the most derived object has a base class, of typeC
, that is unambiguous andpublic
, the result points (refers) to theC
subobject of the most derived object.
Your v
is s1
, which points to a Storable
subobject of a most-derived object of type Radio
. There's only one base class subobject of type Component
in Radio
, and it's public, so the dynamic cast should succeed, as it does.
It would be amgiguous if Radio
was derived from Receiver
as well; perhaps you missed that?