Discussion
A friend function can be used to
Answer: C
A friend function can be used to allow one class to access another, unrelated class. A function declared as a friend of a class can reach its private and protected members, and a friend function of two classes can read the members of both, which gives them a way to share data without being related by inheritance. A friend does not avoid arguments between classes, and it cannot give access to classes whose source code is not available because the friend declaration has to be written inside the class. A common example is an operator function that needs to read the private data of two different classes at once.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development