Something to allow your class to grant access to another class or function.
Friends can be either functions or other classes.
A class grants access privileges to its friends. If they're used properly, they actually enhance encapsulation. You often need to split a class in half when the two halves will have different numbers of instances or different lifetimes. The safest way to implement this is to make the two halves friends of each other. If you use friends like just described, you'll keep private things private .