
3 Dec
2004
3 Dec
'04
3:59 p.m.
Hi, how can I upcast a shared_ptr? class Base { /* ... */ } class Derived : public Base { /* ... */ } shared_ptr<Base> Get( const char* pName ); shared_ptr<Derived> spDerived = *_cast<*>( Get( "Derived" ) ); // What do I need to write instead the * ? Depending on the passed name I like to upcast the returned pointer to a pointer to the derived class. I used a static_cast with raw pointers before. What do I have to use with shared_ptr? Do I need to enable RTTI? Regards, -Dirk