将此指针转换为boost :: shared_ptr?

问题描述

| 我有一个基类,我想将其指针转换为其派生类shared_ptr。在我的情况下,我不能使用继承enable_shared_from_this。那么还有其他有效的方法吗? 例如
typedef boost::shared_ptr <a>  aPtr;
typedef boost::shared_ptr <b>  bPtr;

Class a{
    void fun();
}

class b : public a{
}

a::fun(){

     //how to carry out this conversion below
     bPtr bpointer = dynamic_cast<bPtr>(this);
}
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)