Mastering C++: A Comprehensive Quiz Based on 'Thinking in C++'

Disable ads (and more) with a membership for a one time $2.99 payment

Test your C++ skills with our quiz based on Bruce Eckel's 'Thinking in C++'. Dive into object-oriented programming, advanced topics, and fundamentals. Perfect for learners and experts alike. Assess your knowledge and become a C++ master!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


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

  1. Inheritance

  2. Polymorphism

  3. Friendship

  4. Encapsulation

The correct answer is: 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.