This is because your Parent class inherits enable_shared_from_this twice. Instead, you should inherit it once - through SuperParent. And if you want to be able to get shared_ptr <Parent> in the parent class, you can also inherit it from the following helper class:
template<class Derived> class enable_shared_from_This { public: typedef boost::shared_ptr<Derived> Ptr; Ptr shared_from_This() { return boost::static_pointer_cast<Derived>(static_cast<Derived *>(this)->shared_from_this()); } Ptr shared_from_This() const { return boost::static_pointer_cast<Derived>(static_cast<Derived *>(this)->shared_from_this()); } };
Then
class Parent : public SuperParent, public enable_shared_from_This<Parent>
source share