私は単純なハッシュテーブルテンプレートを持っています.
template <class K, class V, long H(K)>
class HashTableAbs{/* .... */}
//where K is key type, V is value type, H gives hash code for K value
単純な継承クラス
template <class K, class V, long H(K)>
class HashTable:public HashTableAbs<K, V, H> {};
そして、デフォルトのハッシュ関数を使用して、このテンプレートを文字列に特化したいと考えています
template <class V>
class HashTable<std::string, V, strSimpleHash>:public HashTableAbs<std::string, V, strSimpleHash> {};
//where strSimpleHash is long strSimpleHash(std::string)
しかし、このコンパイラをコンパイルしようとすると、これを書きます
test.o: In function `strSimpleHash(std::string)':
test.cpp:(.text+0x0): multiple definition of `strSimpleHash(std::string)'
/tmp/main-i7yPhc.o:main.cc:(.text+0x0): first defined here
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(テストには HashTable が定義されている hashtable.h が含まれます) strSimpleHash は hashtable.h でのみ定義されます
抜け道はありますか?PS 書き間違い失礼しました。私の母国語ではない英語