Ace Your C++ Skills 2026 – Rock the ‘Thinking in C++’ Challenge!

Question: 1 / 565

Which C++ feature allows specific global functions to access private members of a class?

Inheritance

Polymorphism

Friendship

Friendship in C++ allows specific global functions to access private members of a class. This allows for greater flexibility and control in accessing and modifying data within a class. Choices A, B, and D are incorrect because they do not address the question of how specific global functions can access private members of a class. Inheritance allows derived classes to access protected and public members of a base class, but not private members. Polymorphism refers to the ability of objects to take on multiple forms, but it does not directly address the question. Encapsulation is a broader concept that refers to the bundling of data and functions within a class, but it does not specify how private members can be accessed by global functions. Therefore, choice C, friendship, is the correct and most specific answer in this case.

Get further explanation with Examzify DeepDiveBeta

Encapsulation

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy