Difficulty: Medium
Correct Answer: The program will report compile time error.
Explanation:
Introduction / Context:This question examines the difference between declaration and definition, and the role of the linker. A destructor is declared but not defined. Will the program build successfully when an automatic object is created and then destroyed at scope end?
Given Data / Assumptions:
Concept / Approach:Because ~Tab() is odr-used (it must be called at scope exit), the linker requires a definition. Absent an inline defaulted definition or compiler-generated implicit destructor (suppressed by the user-declared one), the program fails to link, commonly reported as a “unresolved external symbol ~Tab”. Many toolchains surface this as a build-time (compile/link) failure.
Step-by-Step Solution:
1) Compilation of translation unit succeeds (signatures are known).2) During linking, the call to ~Tab is referenced.3) No definition is found → link error → build fails before execution.Verification / Alternative check:Provide a trivial definition ~Tab(){}; and the program will link and run, printing 25.
Why Other Options Are Wrong:
Common Pitfalls:Assuming the compiler will synthesize a destructor despite a user-declared (but undefined) one.
Final Answer:The program will report compile time error.
Discussion & Comments