Re: Re:



2011/1/28 Culpian Camilo Martin <camiloculpian gmail com>:
> ok, i'll try it, i have had some troubles doing this:
>
> class foo
> {
>        static ref_ptr<foo> create
>        (
>                return ref_ptr<foo>(new foo());
>        );
>        foo();
>        ~foo();
>        ref_ptr<foo> set_something()
>        {
>                //set something
>
>                return ref_ptr<foo>(this);
>                //for using foo->set_something()->set_something();
>                // oviously the ref_ptr delete "this", and cause a segfault
>                // any idea how can avoid this?
>        }
> }

Would be good to show what is this ref_ptr class...

If the below code segfaults then maybe copy constructor of ref_ptr
does not increment reference count.

ref_ptr<foo> f = foo::create();
f->set_something()->set_something();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]