A friend function possesses certain special characteristics:

  • It is not in the scope of the class to which it has been declared as friend.
  • Since it is not in the scope of the class, it cannot be called using the object of that class.
  • It can be invoked like a normal function without the help of any object.
  • member function, it cannot access the member names directly and has to use an object name and dot membership operator with each member name.
  • It can be declared either in the public or the private part of a class without affecting its meaning.
  • Usually, it has the objects as arguments.

2 comments:

  1. Very informative article.Thank you author for posting this kind of article .



    http://www.wikitechy.com/view-article/friend-function-in-cpp-with-example-program-and-explanation



    Both are really good,
    Cheers,
    Venkat

    ReplyDelete
  2. all those characteristic are from E.balagurusamy's book.

    ReplyDelete