Show the Whole Spell

Why do template function definitions typically need to be in header files rather than .cpp files?

A

Header files are parsed faster, so templates compile more quickly when placed there

B

The C++ standard forbids placing templates in .cpp files

C

The compiler needs to see the full template definition at every call site to generate the type-specific instantiation; a declaration alone is not enough

D

Templates in .cpp files would be compiled as C instead of C++