static_casting from Parent to Child??

Jonathan Wakely jwakely.gcc@gmail.com
Mon Jun 1 18:20:00 GMT 2015


On 1 June 2015 at 18:25, ArbolOne wrote:
> In the bellow sample I get an error saying : cannot convert from
> 'std::shared_ptr<Parent>' to 'Child'

This is not a GCC question, it's a general C++ question, so is off-topic here.


Of course you can't convert shared_ptr<Parent> to Child, they are
totally unrelated. You can't even convert Parent* to Child, one is a
pointer and one is not.

Maybe you mean static_pointer_cast<Child>(e) which converts
pointer-to-Parent to pointer-to-Child.



More information about the Gcc-help mailing list