Jules Bean <[EMAIL PROTECTED]> writes:
| On Wed, Feb 28, 2001 at 11:15:03AM +0000, Angus Leeming wrote:
| > On Wednesday 28 February 2001 09:59, Lars Gullik Bjønnes wrote:
| >
| > > I don't care if it is "ok", you pass a pointer to the button
| > > controller (or whatever) and delete that pointer in the destructor,
| > > what is not nice.
| >
| > Well, I can't disagree with your preferences. Surely though, this is just an
| > example of a class taking over the management of a pointer?
|
| Unless you can give it value semantics with a copy constructor.
|
| Since the button controller is a lightweight object, this may be
| simple enough.
|
| It doesn't seem to gain a lot, though.
... and if nothing else changes... use a scoped_ptr from boost
insted of the manual delete.
#include <boost/smart_ptr.hpp>
class Foo {
public:
Foo(Bar * b) : bc_(b) {}
private:
scoped_ptr<Foo> bc_;
};
Lgb