Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
C++ でテンプレート宣言ファイルと実装ファイルを分離できない理由。この根本的な理由は何ですか。
ありがとう。
.cppそれはできますが、実装をファイルに入れることはできません。
.cpp
理由は簡単です。テンプレートを使用している場合は、タイプを置き換えてインスタンス化されます。別のcppファイルがある場合、実装の代わりに型パラメーターがなく、リンカーはそれらを見つけることができませんでした。