friend function - Features - Functions

Q.  Which of the followings is/are not false about friend function ?

1. It can be called / invoked with class object.
2. It has objects as arguments.
3. It can have built-in types as arguments.
4. It must declared only in public part of a class.
5. It does not have this pointer as an argument.

- Published on 17 Jul 15

a. Only 2,4
b. Only 1,2,5
c. Only 2,3,5
d. All of these

ANSWER: Only 2,3,5
 

    Discussion

  • Nihal   -Posted on 09 Oct 15
    Some of the important properties of friend function is as follows:
    • Generally it has objects as arguments.
    • It can have built-in types as arguments.
    • It does not have this pointer as an argument.
    • Friend functions are not a part of the class.
    • Friend function can access to the class's private and protected members.
    • It can be invoked like a normal function without the help of any object.

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)