• Advertisement
Sign in to follow this  

boost shared_ptr typecast?

This topic is 4334 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey I got these classes 'BaseObject' 'TreeNode' and 'Entity' Entity is a child of TreeNode that again is a child of BaseObject. both are declared as
typedef boost::shared_ptr<BaseObject> BaseObjectPtr;
typedef boost::shared_ptr<TreeNode>   TreeNodePtr;
typedef boost::shared_ptr<Entity>     EntityPtr;
Now I got a BaseObjectPtr and want to upcast it into EntityPtr. like:
BaseObjectPtr pBase( new Entity );

// throws a compiler error, at least at my compiler..
EntityPtr pEntity = pBase;
A example how to achive this would be nice :D Thanks in advance...

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement