Check out example codes for "friend function in c++". It will help you in understanding the concepts better.

Code Example 1

#include <iostream> 
  
class B; 
  
class A { 
public: 
    void showB(B&); 
}; 
  
class B { 
private: 
    int b; 
  
public: 
    B() { b = 0; } 
    friend void A::showB(B& x); // Friend function 
}; 
  
void A::showB(B& x) 
{ 
    // Since showB() is friend of B, it can 
    // access private members of B 
    std::cout << "B::b = " << x.b; 
} 
  
int main() 
{ 
    A a; 
    B x; 
    a.showB(x); 
    return 0; 
}

Learn ReactJs, React Native from akashmittal.com