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 different classes derived from the same base to respond differently to the same function call?

  1. Function overloading

  2. Virtual functions

  3. Templates

  4. Function pointers

The correct answer is: Virtual functions

Virtual functions allow different classes derived from the same base to respond to the same function call in different ways. This is because virtual functions are defined and implemented in the base class, but can be overridden in the derived classes, allowing them to have their own unique implementation of the function. This is known as polymorphism, which allows for more dynamic and versatile code. Function overloading (A) is a different concept where multiple functions can have the same name but different parameters. This does not allow for different responses from classes. Templates (C) are used for generic programming and do not directly impact the way classes respond to function calls. Function pointers (D) are simply pointers to functions and do not have any impact on how classes respond to function calls.