Boost logo

Boost Users :

From: Philipp Henkel (threadpool_at_[hidden])
Date: 2007-01-22 01:31:27


On 1/22/07, ethann.castell_at_[hidden] <ethann.castell_at_[hidden]> wrote:
>
> class A : public base_class
>
> classA::Process()
> {
> boost::shared_ptr<A> ptr_a = shared_from_this(); //
> get pointer to myself
>
> //afterwards - use_count = 2, weak_count = 2
> ...
> if (some_condition){
> boost::shared_ptr<B2> ptr_b2( ptr_a) ;
> // create new B2 and pass pointer to me.
> }else{ //
> crashes with bad_weak_ptr error on this line.
> }
> }
>
>
>

boost::shared_ptr<B2> ptr_b2( ptr_a) does not create a new object of B2. Do
you mean ptr_b2(new B2(ptr_a))?

Could you please post a more complete code sample (at least of Process)?



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net