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 required for an inline function to be effective?

  1. The function must be declared as static.

  2. The function body must be included with its declaration.

  3. The function must return an integer.

  4. The function must be called within a loop.

The correct answer is: The function body must be included with its declaration.

An inline function is a function that is expanded at the point of call. Its body must be included with its declaration in order for it to be effective. This allows the compiler to replace the function call with the body of the function, reducing the overhead of function calls. Declaring a function as static would not necessarily make it an inline function, so option A is incorrect. Option C is incorrect because an inline function does not have to return an integer. Option D is incorrect because a function being called in a loop does not determine whether it is an inline function or not.