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.


When is it suitable to use public inheritance?

  1. When creating a completely new class

  2. When specializing a class

  3. When modifying a base class to create a generic class

  4. When building unrelated classes

The correct answer is: When specializing a class

Public inheritance is suitable when you want to create a class that is a more specialized version of another class. This means that the new class inherits the properties and behaviors of the base class, but also adds its own unique features. Option A is incorrect because you would use public inheritance when creating a more specialized version of an existing class, not a completely new one. Option C is incorrect because it mentions modifying a base class, which is not the purpose of public inheritance. Option D is incorrect because public inheritance is used to create a relationship between related classes, not unrelated ones.