Shared pointer difficulties

Discussion in 'C++' started by Dave, Jan 11, 2005.

  1. Dave

    Dave Guest

    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());
    }
    };
     
    Dave, Jan 11, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DJ Dev
    Replies:
    3
    Views:
    16,240
    Gandalf
    Feb 8, 2004
  2. Joe Fallon
    Replies:
    3
    Views:
    788
    =?Utf-8?B?Z3V5?=
    Jul 16, 2004
  3. ben
    Replies:
    3
    Views:
    532
    Kevin Spencer
    Nov 15, 2004
  4. tshad
    Replies:
    11
    Views:
    849
    tshad
    May 27, 2005
  5. spasmous

    Pointer difficulties

    spasmous, Feb 6, 2009, in forum: C Programming
    Replies:
    13
    Views:
    484
    Ike Naar
    Feb 7, 2009
Loading...

Share This Page