I have already create a shared_ptr,but why i still get the bad_weak_ptr runtime error?Does any one know the reason and how can i do for that?
class base:enable_shared_from_this<base> {
public:
virtual void wtf() { shared_from_this(); };//bad_weak_ptr here
};
class c1 :public base {};
using basep = shared_ptr<base>;
void main() {
basep bp = make_shared<c1>();//shared_ptr here
bp->wtf();
}
Aucun commentaire:
Enregistrer un commentaire