Mastering C++: A Comprehensive Quiz Based on 'Thinking in C++'

Disable ads (and more) with a membership for a one time $2.99 payment

Master C++ with our comprehensive quiz based on 'Thinking in C++'. Test your knowledge through flashcards and multiple-choice questions to enhance your understanding of C++. Prepare effectively for your exam!

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 happens when you redefine a member function of a base class in a derived class?

  1. The derived class function overloads the base class function

  2. The base class function is automatically deleted

  3. The base class function is hidden

  4. The base class function is called by default

The correct answer is: The base class function is hidden

When you redefine a member function of a base class in a derived class, it is called function hiding. This means that the derived class function will override the base class function, and the base class function will no longer be accessible to objects of the derived class. Option A is incorrect as function overloading means having multiple functions with the same name but different parameters, not redefining a function. Option B is incorrect because the base class function is not automatically deleted, it is simply hidden from the derived class. Option D is incorrect as the derived class function will be called instead of the base class function due to function hiding.