
1 Mar
2007
1 Mar
'07
4:51 a.m.
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