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

Question: 1 / 565

How does the C++ compiler ensure that a call to a virtual function binds to the correct function body at runtime?

By creating a fixed function lookup table at compile time

Using a virtual table (VTABLE) and a virtual pointer (VPTR) mechanism

The C++ compiler ensures that a call to a virtual function binds to the correct function body at runtime by using a virtual table (VTABLE) and a virtual pointer (VPTR) mechanism. This means that there is a table of function pointers that the compiler creates at compile time, and a virtual pointer references this table at runtime to determine which function to call. Option A is incorrect because the virtual table is not fixed and can be modified at runtime. Option C is also incorrect because the code itself is not recompiled, but the virtual table is dynamically updated. Option D is also incorrect because C++ does support runtime binding through the use of virtual functions.

Get further explanation with Examzify DeepDiveBeta

By recompiling parts of the code at runtime

C++ does not support runtime binding

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy