When are friends useful? Discuss the pros and cons of using friends
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:7| Question number:20
All Answers
total answers (1)
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:7| Question number:20
total answers (1)
A **friend** of a class can access non
`public`
members of that class.Pros:
- For functions that are part of the interface while not a member of the class, they can access the non
`public`
members of that class.Cons:
- If the implementation of the class changes over time, its friend may also requiring changes.