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.


For pointers and references, what does marking an argument 'const' guarantee to the caller?

  1. The function is more efficient

  2. The object pointed or referred to will not be modified

  3. The function returns a constant value

  4. The function does not throw exceptions

The correct answer is: The object pointed or referred to will not be modified

When an argument is marked 'const' in a function, it guarantees that the object being pointed or referred to will not be modified. This means that the function will not change the value of the object and any modifications made to the object within the function will be discarded once the function ends. This is not the case for the other options. Option A suggests that marking an argument 'const' will make the function more efficient, which is not necessarily true. Option C states that the function returns a constant value, which is unrelated to marking an argument 'const'. Option D mentions that the function does not throw exceptions, which is also unrelated to marking an argument 'const'.