The friend keyword in C++ is one of those concepts that is formally taught, but then seems to disappear off the scene once you get into the real world. Maybe friends are less common in embedded programming (ha ha), but I’ve seen very few of them over the years.
The thing is, they just don’t seem to be at the forefront of people’s minds when writing code. When would you ever actually use one of these things?
Aren’t they just a way to avoid writing getters and setters??
I think when you are learning a language, understanding concrete examples of why a concept is there is absolutely necessary if that concept is to stick and be used well.
So let’s have a look at friend functions and classes and see what on earth we could do with them.