What is a friend function & its advantage?

Answers were Sorted based on User's Feedback



What is a friend function & its advantage?..

Answer / supriya

friend function is the one that can access the private data
members of the class to which it is made as friend. this is
advantageous when any class needs any computation which
requires the private data members of two different classes.
in such case that class can be made as friend to both the
classes whose data it needs

Is This Answer Correct ?    27 Yes 4 No

What is a friend function & its advantage?..

Answer / devi

The above ans is also right.
->Friend function is the one that can access the private
data members of the same class and other class which it is
made as friend.
->The advantageous of friend function that function not called
by object of the class.
->That means without using object name and dot operator that call the friend function.It
can define private area and public area.
->The friend function define outside the class without using
the class name and scope resolution operator.

Is This Answer Correct ?    16 Yes 7 No

Post New Answer

More OOPS Interview Questions

What is the real life example of polymorphism?

0 Answers  


when to use 'mutable' keyword and when to use 'const cast' in c++

0 Answers   TCS,


String = "C++ is an object oriented programming language.An imp feature of oops is classes and objects".Write a pgm to count the repeated words from this scenario?

0 Answers   HCL,


What is Inheritance, Multiple Inheritance, Shared and Repeatable Inheritance?

4 Answers   Accenture, L&T,


Why do we use polymorphism in oops?

0 Answers  






Name an advantage of linked list over array?

11 Answers   IBM, Infosys,


namespace is working on which compiler?

3 Answers  


Which language is pure oop?

0 Answers  


I am DeePu sotware engineer working with EMC corporation ,recently I had attended mcafee interview . Their questions were at heights of stupidity , I don't know what they want , I am a developer with 4 year experienced .I am listing the questions asked 1:What is the flag in g++ to avoid structure padding 2:In wht order parameters are passed to stack 3:How you will edit code segment of an exe

1 Answers  


Why do we use virtual functions?

4 Answers  


Get me an image implementation program.

0 Answers  


write a c++ code to overload + and - for a stack class such that + provides push and - provides pop operation

1 Answers   College School Exams Tests, HCL, IBM, TCS,


Categories