Question
Download Solution PDFGiven below are two statements:
Statement (I): The friend function and the member functions of a friend class directly access the private and protected data.
Statement (II): The friend function can access the private data through the member functions of the base class
In the light of the above statements, choose the most appropriate answer from the options given below:
Answer (Detailed Solution Below)
Detailed Solution
Download Solution PDFThe correct answer is option 3: Statement I is correct but Statement II is incorrect
Key Points
- Friend Function: A friend function in C++ is a function that is not a member of a class but has access to its private and protected members. It is declared using the keyword
friend
inside the class. - Friend Class: All member functions of a friend class can directly access private and protected members of the class that declared it as a friend.
Statement I: TRUE ✅
- The friend function and member functions of a friend class can directly access the private and protected data of the class in which they are declared as friend.
- This is by definition of friendship in C++.
Statement II: FALSE ❌
- A friend function does not need to go through member functions of the base class to access private members.
- It either has direct access (if declared friend), or it doesn’t have access at all.
- Also, friend functions are not inherited through base classes — so they don't have privileged access via base class methods unless explicitly declared as friend in that class.
Hence, only Statement I is correct.
Final Answer: Option 3) Statement I is correct but Statement II is incorrect
Last updated on Jul 7, 2025
-> The UGC NET Answer Key 2025 June was released on the official website ugcnet.nta.ac.in on 06th July 2025.
-> The UGC NET June 2025 exam will be conducted from 25th to 29th June 2025.
-> The UGC-NET exam takes place for 85 subjects, to determine the eligibility for 'Junior Research Fellowship’ and ‘Assistant Professor’ posts, as well as for PhD. admissions.
-> The exam is conducted bi-annually - in June and December cycles.
-> The exam comprises two papers - Paper I and Paper II. Paper I consists of 50 questions and Paper II consists of 100 questions.
-> The candidates who are preparing for the exam can check the UGC NET Previous Year Papers and UGC NET Test Series to boost their preparations.