static and protection

Derek Parnell derek at psych.ward
Wed Mar 1 18:37:07 PST 2006


On Wed, 01 Mar 2006 18:22:06 -0700, Hasan Aljudy wrote:

>> However a better analogy is "I will let my neighbour come over and 
>> use  my basketball hoop, but not the general public."


> Why would you *not* allow the general public to play with your hoop?
> obviously, if you neighbour can play with it without negatively altering 
> your state (as an object), then everyone else should be allowed to play, 
> since they too won't be able to negatively alter your state.

Its a 'trust' thing. I trust my neighbour more than I trust unknown people.
 

> Can you give me a real life example where one class needs to expose 
> certain parts of itself to only one or two other classes? and why would 
> providing a public accessor for this feild be a bad thing?

The 'friend' concept can be used as a compromise to gain runtime
performance.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
2/03/2006 1:34:54 PM



More information about the Digitalmars-d mailing list