On Tue, Mar 12, 2002 at 09:32:07AM +0100, Lars Gullik Bjønnes wrote:
> | Bad example. No class should contain more than one raw 'owned' pointer
> | is a better rule...
> 
> And _way_ harder to enforce..., and also please explain why this is a
> bad example? And why shouldn't a class contain more than one pointer?

And most one _raw_ _owning_ pointer.

One is sometimes necessary for low level classes wrapping resources (like
vector etc). Anything else should use these wrappers. A class that wraps
two 'raw' resources does too much.

> Does this one suid you better:
> 
> class Foo {
>       // unsafe
>       Foo()
>       : bar(new Bar), str(10, 'n')
>       {}
>       // safeer
>       Foo()
>       : str(10, 'n')
>       {
>         bar = new Bar;
>       }
> private:
>         Bar * bar;
>         string str;
> };

No. Bar * should be wrapped in a class of its own with value semantics.

[Apart from that I am always a bit reluctant to follow schemes that make
code longer. And according to the other LyX rules the 'safer' version is
two lines longer...]

Andre'

-- 
André Pönitz .............................................. [EMAIL PROTECTED]

Reply via email to