Difficulty: Easy
Correct Answer: The program will print the output Char .
Explanation:
Introduction / Context:
This question checks C++ overload resolution and object lifetime when allocating with new without a corresponding delete. Multiple constructors accept integral-like parameters, and a character literal is passed. Which overload is a best match?
Given Data / Assumptions:
Concept / Approach:
Overload resolution prefers the exact match over promotions or conversions. The argument 'B' has type char, so the constructor CuriousTab(char) is an exact match. Short or int would require a conversion/promotion that is strictly worse than an exact match.
Step-by-Step Solution:
Verification / Alternative check:
Change the literal to 66 (an int) and you will see "Int". Use (short)'B' to force "Short".
Why Other Options Are Wrong:
Common Pitfalls:
Confusing integral promotions with exact matches, and expecting destructors to run for leaked objects at program end.
Final Answer:
The program will print the output Char .
Discussion & Comments