Skip to main content


Non-member actions of a class will not have accessibility to another class’s secret data. There may be times when we need two classes to share some methods and data members. In such a situation, we may declare the function a buddy of these classes, allowing it to access the classes’ secret and protected data members. In this post, we’ll look at how to add a non-member function to a class as a friend. In this blog, we will help you understand what is friend function.