|
Boost : |
From: Michael Marcin (mike_at_[hidden])
Date: 2007-02-28 23:51:21
Michael Anderson wrote:
> Howdy everyone.
> I have some code that uses pointers to member variables that I want to
> switch to using boost::shared_ptrs, some of the code looks like this.
>
> class Bar {};
> class Foo
> {
> public:
> Bar bar;
> };
>
> ...
> Foo * fooptr = new Foo;
> Bar * barptr = &Foo.bar;
> ...
>
> So to make this work with shared_ptrs I can do this:
>
> class Bar {}
> class Foo
> {
> public:
> Foo() : bar(new Bar) {}
> shared_ptr<Bar> bar;
> };
>
> ...
> <snip>
>
Pardon my ignorance but why not just use scoped_ptr<Bar>?
- Michael Marcin
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk