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.


What C++ feature provides behavior similar to but safer than enums in C?

  1. Namespaces

  2. Classes

  3. Templates

  4. Inheritance

The correct answer is: Classes

Classes in C++ provide behavior similar to enums in C but with additional safety. Namespaces (A) provide a way to group related functions, classes, and variables but are not meant for data representation. Templates (C) are used for generic programming and allow for creating types and functions that are used with various data types but are not the same as enums in C. Inheritance (D) enables code reusability and establishes a parent-child hierarchy, but is not a direct replacement for enums in C. Therefore, the most suitable answer is B, classes.