friend functions c++
In object-oriented programming, a friend function that is a “friend” of a given class is allowed access to private and protected data in that class that it would not normally be able to access if the data was private.
Example
#include <iostream> class B { private: friend void privatePrint() { std::cout << "friend functions" << std::endl; } }; class A { public: A() { // no need to access private part with public members of B privatePrint(); // direct calling } }; int main() { A a; getchar(); return 0; }
Output :
friend functions