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 does the 'sizeof' operator return when applied to a class derived through inheritance?

  1. The size of the base class

  2. The size of the derived class

  3. The combined size of the base and derived classes

  4. Cannot be determined

The correct answer is: The size of the derived class

The 'sizeof' operator returns the size of the derived class when applied to a class derived through inheritance. This is because a derived class inherits all of the non-static members and member functions of the base class, thus the size of the derived class includes the size of the base class as well. Options A and C are incorrect as they refer to the size of the base and derived classes combined, while option D is incorrect as it implies that the 'sizeof' operator cannot determine the size of a derived class, which is not true.