Shared pointer difficulties

D

Dave

Hello all,

In the code below, I am experiencing shared pointer problems. Specifically,
the call to shared_from_this() is dying. Can anybody out there see what I'm
doing wrong???

Thanks,
Dave


class B;
typedef boost::weak_ptr<B> WpB;

class A
{
public:
A(WpB wpB): m_wpB(wpB) {}
private:
WpB m_wpB;
};

typedef boost::shared_ptr<A> SpA;

class B: public boost::enable_shared_from_this<B>
{
public:
void foo()
{
SpA spA = SpA(new A(shared_from_this());
}
};
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top