Difficulty: Easy
Correct Answer: Declaration
Explanation:
Introduction / Context:In multi-file C/C++ projects, header files commonly contain 'extern' declarations of globals. Understanding how 'extern' changes the meaning of a statement prevents multiple-definition linker errors while allowing many translation units to reference the same variable defined elsewhere.
Given Data / Assumptions:
Concept / Approach:
Step-by-Step Solution:
Classify 'extern int i;' → declaration only (no storage allocated).Recognize that definition would be 'int i;' (or with initialization) in exactly one source file.Thus, the statement is a declaration.Verification / Alternative check:
Placing 'extern int i;' in a header included in many files compiles; the program links only if one file defines 'int i;' once.Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:
Declaration
Discussion & Comments