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.


In what situation is an inline function not preferable over a preprocessor macro?

  1. When the function body is very small.

  2. When the function needs to access private members.

  3. When preprocessor text substitution is specifically required.

  4. When type checking for arguments is needed.

The correct answer is: When preprocessor text substitution is specifically required.

Inline functions are preferable over preprocessor macros in situations where type checking for arguments is needed. This is because preprocessor text substitution does not perform type checking, which can lead to errors in the code. Additionally, inline functions have the advantage of being able to access private members, unlike preprocessor macros. However, if preprocessor text substitution is specifically required for some reason, then an inline function would not be a preferable choice. In this situation, using a preprocessor macro would be necessary.