Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
friend is a keyword to grant private access to a function, member function or class.
Avoid unnecessary friendships [1]. Avoiding granting friendship to individual functions [2].
In this example, operator<< is made a friend of class MyClass, so that operator<< can access the private variable mValue.
#include <iostream> |
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.