Friend Function in C++ Definition A friend function in C++ is a special function that can access private and protected members of a class, even though it is not part of that class. Normally, private and protected members of a class can only be accessed by the class's own methods or its friends. To make a function a friend of a class, we declare it inside the class definition using the keyword friend . Why Do We Use Friend Functions? We use a friend function to allow an external function access to private or protected data of a class without making it a member of that class. Need for Friend Functions 1. Access Private Data : Helps an external function work with private or protected members of a class. 2. Convenience : Simplifies code by avoiding the use of getters or setters. 3. Specialized Use : Useful when an external function needs a special relationship with the class. Advanta...