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. Advertisements

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,779
    Gandalf
    Feb 8, 2004
  2. Replies:
    10
    Views:
    977
    Chris Torek
    Feb 4, 2005
  3. jimjim
    Replies:
    16
    Views:
    1,095
    Jordan Abel
    Mar 28, 2006
  4. spasmous

    Pointer difficulties

    spasmous, Feb 6, 2009, in forum: C Programming
    Replies:
    13
    Views:
    587
    Ike Naar
    Feb 7, 2009
  5. Replies:
    4
    Views:
    1,635
    Fred Zwarts
    Jul 2, 2009
  6. A
    Replies:
    7
    Views:
    799
  7. , India

    pointer to an array vs pointer to pointer

    , India, Sep 20, 2011, in forum: C Programming
    Replies:
    5
    Views:
    770
    James Kuyper
    Sep 23, 2011
  8. arnuld

    pointer vs pointer to pointer

    arnuld, Jun 11, 2012, in forum: C Programming
    Replies:
    4
    Views:
    631
    Ben Bacarisse
    Jun 11, 2012
Loading...