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 is a consequence of arguments in macros being evaluated every time they are used?

  1. The return value of macros cannot be used.

  2. The execution time of the macro increases.

  3. Side effects can occur if arguments have side effects.

  4. The macro cannot accept more than one argument.

The correct answer is: Side effects can occur if arguments have side effects.

Side effects occur when a function or operation modifies a variable or other condition outside of its own scope. If macros are evaluated every time they are used, this means that the arguments passed into the macro will also be evaluated every time, potentially resulting in unexpected side effects. Options A, B, and D are incorrect because they do not address the issue of side effects. Option A is incorrect because the return value of macros can still be used, even if arguments are evaluated every time. Option B is incorrect because the execution time of the macro may not necessarily increase, depending on the arguments passed in. Option D is incorrect because macros can still accept multiple arguments, even if they are evaluated every time. Therefore, the correct answer is C, as it explains the potential consequence of having arguments in macros that are evaluated every time they are used.