Difficulty: Medium
Correct Answer: The program reports linker error.
Explanation:
Introduction / Context:
This snippet tests knowledge of static member functions and function pointers in C++. Static member functions have no implicit object parameter and can be used like ordinary free functions with respect to taking their addresses. The subtlety here is the difference between successful compilation and successful linking.
Given Data / Assumptions:
Concept / Approach:
Taking the address of a static member function is legal and yields an ordinary function pointer type compatible with void()(). The code will compile because the declaration is visible and the types match. However, because the function is only declared and never defined, the linker cannot resolve the symbol CuriousTab::MyFunction, producing an unresolved external reference (linker error).
Step-by-Step Solution:
1) Parse declarations: static member → no this pointer → OK to form &CuriousTab::MyFunction.2) Type check: assignable to void()() → OK.3) Linking: reference to MyFunction must bind to a definition; none exists.4) Result: link fails with an unresolved symbol error.
Verification / Alternative check:
Add a definition: void CuriousTab::MyFunction() {}. Rebuild → program links successfully. Removing the assignment or not using the symbol may still require a definition depending on optimization; conservatively, the missing definition is a link-time error.
Why Other Options Are Wrong:
A/B/C: Misstate pointer rules; static member functions are addressable via ordinary function pointers without an object.E: Incorrect because the symbol remains undefined at link time.
Common Pitfalls:
Confusing pointer-to-member-function syntax (for non-static members) with static members. Non-static member pointers have type like void (Class::*)() and require an instance to invoke.
Final Answer:
The program reports linker error.
Discussion & Comments