Question 46
What hidden pointer is added to each object of a polymorphic class to point to its class VTABLE?
Option B is correct. Each object of a class with virtual functions contains a hidden VPTR (virtual pointer) pointing to the class VTABLE.
What hidden pointer is added to each object of a polymorphic class to point to its class VTABLE?
Option B is correct. Each object of a class with virtual functions contains a hidden VPTR (virtual pointer) pointing to the class VTABLE.
What is composition in Object-Oriented Design?
Option C is correct. Composition models a 'has-a' relationship where a composite object contains component objects as members.
Which cast operator in C++ is used to cast away 'const' or 'volatile' qualifiers from a variable?
Option E is correct ('None of the above'). const_cast is specifically designed to add or remove const/volatile modifiers from pointers or references.
Which cast operator in C++ performs low-level reinterpretation of bit patterns (e.g., casting an integer to a pointer)?
Option B is correct. reinterpret_cast performs unsafe low-level bit reinterpretation between unrelated pointer or integer types.
What is the lifetime of a local static variable declared inside a function in C++?
Option A is correct. A local static variable is initialized once on first control pass and retains its value in global static memory until program termination.