Friends

Q: What is a friend?

Q: Do friends violate encapsulation?

Q: What are some advantages/disadvantages of using friend functions?

Q: Should my class declare a member function or a friend function?

Q: How can I provide printing for my class Fred?

Q: But shouldn't I always use a printOn() method rather than a friend function?

Q: How can I provide input for my class Fred?

Q: How can I provide printing for an entire hierarchy of classes?

你可能感兴趣的:(Friends)