How do headers and source files form translation units, and which declarations or definitions may live in headers without violating the ODR?
Show answer and explanation
After preprocessing, each source file together with the headers it includes becomes a translation unit; a header is not a separate language unit. Headers normally contain declarations and definitions intended to appear identically in several translation units, including class definitions, templates, inline functions, and inline variables. Those definitions must satisfy the ODR's identity and lookup requirements. An ordinary non-inline definition with external linkage in a widely included header usually causes multiple-definition errors or an ODR violation. Include guards prevent repeated inclusion within one translation unit, not duplicate external definitions across translation units; put such a definition in one source file instead.
After preprocessing, each source file together with the headers it includes becomes a translation unit; a header is not a separate language unit. Headers normally contain declarations and definitions intended to appear identically in several translation units, including class definitions, templates, inline functions, and inline variables. Those definitions must satisfy the ODR's identity and lookup requirements. An ordinary non-inline definition with external linkage in a widely included header usually causes multiple-definition errors or an ODR violation. Include guards prevent repeated inclusion within one translation unit, not duplicate external definitions across translation units; put such a definition in one source file instead.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.