Jim Smith wrote:
> You could also just make one member function a friend, but including the 
> friend feature is not a good idea.

Using 'friend' can significantly decrease development time - but only if 
it is used properly.  That is true for any language construct (e.g. 
'goto').  Example of what I consider appropriate 'friend' usage:

class A
{
public:
   class B;

   friend class B;

private:
   ...
};

class A::B
{
private:
   ...
};

Where B needs to access the protected/private data of A.  Here it makes 
sense as B is clearly a logical sub-category of A to support A.  Could 
you put all of B into A?  Probably.  But it would also "pollute" the 
purity of A.  I'm sure there is also some pure OO method as well that 
doesn't use 'friend', but if something gets the job done AND results in 
easily maintained code (and possibly fewer lines of it) that the entire 
team understands but just happens to be non-OO, which is better?

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

Reply via email to