Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   C++ friend functions (http://www.go4expert.com/forums/cpp-friend-functions-t29088/)

coder12 15Sep2012 12:46

C++ friend functions
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)

shabbir 15Sep2012 12:49

Re: C++ friend functions
Moved to C++ Forum

ballurohit 21Apr2014 18:38

Re: C++ friend functions

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.

    #inclulde <iostream>
  #include <stdlib.h>
  using namespace std;
  class Value
      int  m_nValue;
    Value(int nValue) {m_nValue=nVallue;}
  friend bool IsEqual(const Value &cValue1, const Value &cValue2);
  return (Value1.m_nValue==cValue2.m_nValue);

All times are GMT +5.5. The time now is 07:53.