ProAnswers.org

why does `friendship function is neither inherited nor transitive' in c++?

The access privilege of friendship is not inherited:

  • I may trust you, but I don’t necessarily trust your kids.
  • My friends aren’t necessarily friends of my kids.
  • Class Base' declares f() to be a friend, but f() has no special access rights with classDerived’.

The access privilege of friendship is not transitive:

  • I may trust you, and you may trust Sam, but that doesn’t necessarily mean
    that I trust Sam.
  • A friend of a friend is not necessarily a friend.