English

State Characteristics of Friend Function.

Advertisements
Advertisements

Question

State characteristics of Friend Function.

Long Answer
Advertisements

Solution

  1. Even though it’s declared inside a class, it isn’t a “member.” You don’t use object.function() To call it, you just call it like a regular function.
  2. This is a common point of confusion. While it has permission to see private data, it doesn't "live" inside the object, so it must be told which object to look at using the dot operator (e.g., obj.data).
  3.  It doesn't matter if you put the friend declaration under public: or private:Its status and access rights remain exactly the same.
  4. Since it’s not a member function (and doesn’t have a this pointer), it almost always takes an object of the class as a parameter, so it has something to work on.
shaalaa.com
  Is there an error in this question or solution?
2015-2016 (March)
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×