11.8 — Using function templates in multiple files
Consider the following program, which doesn’t work correctly: main.cpp: #include <iostream> template <typename T> T addOne(T x); // function template forward declaration int main() { std::cout << addOne(1) << ‘\n’; std::cout << addOne(2.3) << ‘\n’; return 0; } add.cpp: template <typename T> T addOne(T x) // function template definition { …