Discussion
In C++, which of the following is true for private members of a class ?
Answer: B
Private members are accessible only within the same class.
In C++, private members can be used only by the class's own member functions (and by its friends). This is the basis of encapsulation.
They cannot be accessed by other classes, and derived classes cannot access them directly either; that is what protected members allow. The this pointer is used inside member functions, so it does not open private members to outside code.
No comment is present. Be the first to comment.
Loading…
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