Difficulty: Easy
Correct Answer: The program will print the output 76.
Explanation:
Introduction / Context:
This snippet allocates an int on the heap, computes a sum using an integer literal and the numeric code of a character, and prints the result. Understanding how chars convert to int in C++ is the key here.
Given Data / Assumptions:
Concept / Approach:
In C and C++, characters are small integer types. Converting a char to int yields its code point (commonly ASCII in this context). Therefore the arithmetic expression 10 + 66 evaluates to 76, which is then printed. Memory is correctly freed in the destructor, avoiding leaks.
Step-by-Step Solution:
Verification / Alternative check:
Replace 'B' with 'a' (97) to see 107. Replace 10 with 0 to print the character code itself.
Why Other Options Are Wrong:
Common Pitfalls:
Expecting character concatenation semantics (like strings) instead of integer arithmetic with char.
Final Answer:
The program will print the output 76.
Discussion & Comments