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!

Practice this question and more.


What determines the size difference between objects with and without virtual functions?

  1. The number of functions

  2. The size of the VTABLE

  3. The inclusion of a VPTR

  4. The amount of data members

The correct answer is: The inclusion of a VPTR

The size of objects with virtual functions is determined by the inclusion of a VPTR (Virtual Pointer), which is a pointer to the virtual table (VTABLE) that is created by the compiler for classes with at least one virtual function. The VTABLE itself is not responsible for the size difference, as it exists regardless of the presence of virtual functions. Similarly, the number of functions or data members do not directly affect the size difference.