#include #include #include #include class base : public boost::enable_shared_from_this { public: boost::shared_ptr get_shared_from_base() { return shared_from_this(); } }; class derived : public base, public boost::enable_shared_from_this { public: boost::shared_ptr get_shared_from_derived() { return boost::enable_shared_from_this::shared_from_this(); } }; int main() { boost::shared_ptr thing = boost::make_shared(); boost::shared_ptr derived_thing = thing->get_shared_from_derived(); boost::shared_ptr base_thing = thing->get_shared_from_base(); return 0; }