Friend classes are used when we need to override the rule for private and protected access specifiers so that two classes can work closely with each other.
Hence, we can have a friend class to be a friend of another class. This way, friend classes can keep private, inaccessible things in the way they are.
When we have a requirement to access the internal implementation of a class (private member) without exposing the details by making the public, we go for friend functions.