11 Sep
2008
11 Sep
'08
1:41 p.m.
On Thu, Sep 11, 2008 at 2:18 PM, Patrick Loney
I notice that the creation of a new object for the scoped pointer has been done before the MyClass constructor. However you can't declare the scoped pointer as a member variable and then do something like this in a method:
Creation of the object is done in the constructor, though not in the curly > brackets.
Why is that?
You can do this:
Change that to return a reference to the ptr:
boost::scoped_ptr<int>& newObject() { ptr.reset( new int ); *ptr = 0; return ptr; }
Or
void newObject() { Ptr.reset( new int ); *ptr = 0; }
I never realised scoped_ptr had a reset() method! I knew auto_ptr did. UberMongoose - ignore my earlier reply.