Top "Friend-function" questions

In C++ friend function is a kind of 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 as if the data was public.

Operator overloading : member function vs. non-member function?

I read that an overloaded operator declared as member function is asymmetric because it can have only one parameter and …

c++ operator-overloading member-functions friend-function non-member-functions
c++ error C2662 cannot convert 'this' pointer from 'const Type' to 'Type &'

I am trying to overload the c++ operator== but im getting some errors... error C2662: 'CombatEvent::getType' : cannot convert 'this' …

c++ operator-overloading syntax-error friend-function
Where would you use a friend function vs. a static member function?

We make a non-member function a friend of a class when we want it to access that class's private members. …

c++ friend-function static-functions
Template friend function of a template class

I was struggling with the issue described in this question (declaring a template function as a friend of a template …

c++ visual-c++ templates friend-function
Can 2 classes share a friend function?

Today i have a doubt regarding friend function. Can two classes have same friend function? Say example friend void f1(); …

c++ friend-function
Declaring a namespace as a friend of a class

I was wondering if there is a way such that we make all functions defined within a specific namespace friend …

c++ namespaces friend-function friend-class
overloading operator<< to output object members without using friend function

I am refreshing cpp after a long gap, trying to understand the operator overloading methods. I tried to overload "operator&…

c++ operator-overloading friend-function