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 allows for the creation of compile-time constants inside classes?

  1. The volatile keyword

  2. The const keyword

  3. Inline functions

  4. Default arguments

The correct answer is: The const keyword

The correct answer is B. The const keyword allows for the creation of compile-time constants inside classes. By using the const keyword, we can designate a variable as a constant, meaning its value cannot be changed. This is useful for creating variables that we want to remain constant throughout the execution of our code. Option A, the volatile keyword, is incorrect because it is used to indicate that a variable may be changed by external factors, and not for creating compile-time constants. Option C, inline functions, is incorrect because they are used for improving performance by reducing function call overhead, and not for creating compile-time constants. Option D, default arguments, is incorrect because they are used for specifying default values for function parameters, and not for creating compile-time constants.