Question 1302 – Nielit STA [02-12-2018]
December 10, 2023
Question 1306 – Nielit STA [02-12-2018]
December 10, 2023
Question 1302 – Nielit STA [02-12-2018]
December 10, 2023
Question 1306 – Nielit STA [02-12-2018]
December 10, 2023

OOPS

Question 105
A friend function in C++ can’t be used with:
A
Member function
B
Object
C
Class
D
Class template
Question 105 Explanation: 
→A C++ friend functions are special functions which can access the private members of a class.
→A friend function is declared by the class that is granting access, so friend functions are part of the class interface, like methods.
→Friend functions allow alternative syntax to use objects, for instance f(x) instead of x.f(), or g(x,y) instead of x.g(y). Friend functions have the same implications on encapsulation as methods.
→Friend of the class can be member of some other class.
→Friend of one class can be friend of another class or all the classes in one program, such a friend is known as GLOBAL FRIEND.
→Friend can access the private or protected members of the class in which they are declared to be friend, but they can use the members for a specific object.
→Friends are non-members hence do not get “this” pointer.
→Friends, can be friend of more than one class, hence they can be used for message passing between the classes.
→Friend can be declared anywhere (in public, protected or private section) in the class.
Correct Answer: B
Question 105 Explanation: 
→A C++ friend functions are special functions which can access the private members of a class.
→A friend function is declared by the class that is granting access, so friend functions are part of the class interface, like methods.
→Friend functions allow alternative syntax to use objects, for instance f(x) instead of x.f(), or g(x,y) instead of x.g(y). Friend functions have the same implications on encapsulation as methods.
→Friend of the class can be member of some other class.
→Friend of one class can be friend of another class or all the classes in one program, such a friend is known as GLOBAL FRIEND.
→Friend can access the private or protected members of the class in which they are declared to be friend, but they can use the members for a specific object.
→Friends are non-members hence do not get “this” pointer.
→Friends, can be friend of more than one class, hence they can be used for message passing between the classes.
→Friend can be declared anywhere (in public, protected or private section) in the class.
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x
error: Alert: Content selection is disabled!!