この質問に対するsthの回答から始めます。
次のコードが異なる.ccファイルに複数回インクルードされてリンクされているヘッダーファイルに入れられた場合、複数の定義エラーを解決する方法を考えていました。
template <typename T>
class C {
static const int K;
static ostream& print(ostream& os, const T& t) { return os << t;}
};
// general case
template <typename T>
const int C<T>::K = 1;
// specialization
template <>
const int C<int>::K = 2;