What is friend function?

Answer Posted / mital

A friend function is used in object-oriented programming to
allow access to private or protected data in a class from
outside the class. Normally a function which is not a
member of a class cannot access such information; neither
can an external class. Occasionally such access will be
advantageous for the programmer; under these circumstances,
the function or external class can be declared as a friend
of the class using the friend keyword. The function or
external class will then have access to all information –
public, private, or protected – within the class.

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can an interface inherit a class?

772


What are the 4 pillars of oop?

882


What is destructor give example?

807


What is the point of oop?

852


What is abstraction and encapsulation?

764


What is the real life example of polymorphism?

841


What are constructors in oop?

786


Is enum a class?

778


Can a varargs method be overloaded?

802


When not to use object oriented programming?

765


What is inheritance in oop?

791


Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)

1841


What is abstraction in oops with example?

984


What makes a language oop?

814


What is meant by multiple inheritance?

926