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
Which C++ operators can not be overloaded without friend function?

Which C++ operators can not be overloaded at all without friend function?

c++ operator-overloading friend-function
Are friend functions inherited? and why would a base class FRIEND function work on a derived class object?

class baseClass { public: friend int friendFuncReturn(baseClass &obj) { return obj.baseInt; } baseClass(int x) : baseInt(x) {} private: int baseInt; }; …

c++ class inheritance friend friend-function
Friend protected method in c++

I've got a class Foo that must be accessed "directly" in other class Bar. I'd like to build a little …

c++ friend-function