dynamic cast of a shared_ptr
I have a few classes of which I've made std::shared_ptr versions, as follows: typedef std::shared_ptr<MediaItem> MediaItemPtr; typedef std::shared_ptr<ImageMediaItem> ImageMediaItemPtr; class MediaItem { //stuff here } class ImageMediaItem : public MediaItem { //more stuff here } Internally, I pass everything around as a MediaItemPtr object, but when I try to cast to a ImageMediaItemPtr, nothing I try seems to work. For example: ImageMediaItemPtr item = std::dynamic_pointer_cast<ImageMediaItemPtr>(theItem); //theItem is MediaItemPtr Fails with error C2440: 'initializing' : cannot convert from