can 2 classes have one common friend function?if yes,then how can it be accessed from the classes?(the friend function is defined outside of both the classes)
Yes, A friend function can access the private or publilc members of a class as it were members of those classes. I would represent the following example though it is not :worried:exhaustive. Code: #inclulde <iostream> #include <stdlib.h> using namespace std; class Value { private: int m_nValue; public: Value(int nValue) {m_nValue=nVallue;} friend bool IsEqual(const Value &cValue1, const Value &cValue2); }; { return (Value1.m_nValue==cValue2.m_nValue); }