Ace Your C++ Skills 2025 – Rock the ‘Thinking in C++’ Challenge!

Image Description

Question: 1 / 565

How does adding a single virtual function affect the size of an object?

Increases by the size of an int

No change

Increases by the size of a void pointer

Adding a single virtual function does not affect the size of an object if the object already has virtual functions. This is because the object already contains a pointer to the virtual function table (vtable). However, if the object did not previously have virtual functions, adding a single virtual function will increase the size of the object by the size of a void pointer. This is because the vtable pointer needs to be added to the object's structure, which typically is the size of a void pointer. Therefore, options A, B, and D are incorrect because they do not accurately describe how adding a single virtual function affects the size of an object.

Get further explanation with Examzify DeepDiveBeta

Decreases because of optimization

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy