Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-10-31 14:19:16

From: <williamkempf_at_[hidden]>

> --- In boost_at_y..., "Kevin S. Van Horn" <kevin.vanhorn_at_n...> wrote:

[many interesting things that I agree with]

> > [I discussed Three possibilities: (1) public member function; (2)
> friend
> > function; (3) non-member, non-friend function. I stated that I
> prefered (3)
> > when possible, and lean toward (2) over (1). The reason is to
> limit access
> > to the internals of a class to only those functions really needing
> it.]
> There's a reason to prefer (3) in a general sense. I forget the OO
> principles name, but in essence the public interface should
> be "minimal but complete". This principle can be taken too far,
> however.
> (2) on the other hand should never be prefered. Friend functions are
> fragile and can open the code up to abuse.


> They also clearly
> illustrate that the above principle wasn't adhered to.


> 1) Why should you prevent them from writing x.some_operation()?

Because you can't make a member function non-friend.

Peter Dimov
Multi Media Ltd.

Boost list run by bdawes at, gregod at, cpdaniel at, john at