If I have three classes, A, B, C. A and B are friends (bidirectionally). Also, B and C are friends (bidirectionally). A has a pointer to B and B has a pointer to C. Why can't A access C's private data through the pointer?
Just to clarify: This is a pure theoretical C++ language question, not a design advice question.
John is a friend of mine and he can use my wireless connection any time (I trust him).
John's friend Tim though is a waster and though John is my friend I do not include Tim as a friend, and thus I don't let him use my wireless connection.
Also John's children are a bunch of hooligans so I don't trust them either they are definitely not my friends nor are my own children who I trust as far as I could throw them.
Though our children can not directly accesses the wireless they can get access to it if they go through us. So John's children can access my wireless if they access it via John (ie they are supervised and protected by John).
John has a goverment job so he unfortunately is not allowed to trust anyone, especially when it comes to wireless.
This allows things like copy constructors where you can access the private member of another object even though there is no real accesses.
So I am also automatically friends with all my clones :-) as they are just other instances of myself.