나는 다음과 같은 오류가 자신을 해시 테이블을 구현 발견 해요 :C++ 템플릿 클래스 컴파일 오류
19 template <class key, class value>
20 class HashEntry { ... }
60 template <class key, class value>
61 class HashTable
62 {
63
64 private:
65 size_t _tableSize;
66 HashEntry<key, value>** _table;
67
68 public:
69
70 HashTable(size_t s)
71 {
72 _tableSize = s;
73 _table = (HashEntry<key, value>**) smalloc(s * sizeof(HashTable<key, value>*));
74 }
75
76 void addEntry(HashEntry<key, value>(key k, value v)) <---
77 {
78
79 }
80
...
91 };
93 int main()
94 {
95 HashTable<int, string> t(100);
96 t.addEntry(HashEntry<int, string>(1, string("a"))); <---
HASH_chaining.cc:96: error: no matching function for call to ‘HashTable<int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >::addEntry(HashEntry<int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >)’
HASH_chaining.cc:76: note: candidates are: void HashTable<key, value>::addEntry(HashEntry<key, value> (*)(key, value)) [with key = int, value = std::basic_string<char, std::char_traits<char>, std::allocator<char> >]
한눈에, 나는 그것이 잘못 아무것도 찾을 could't. 내가 addEntry 인터페이스를 정의하는 방식과 관련이 있다고 생각한다.
감사합니다.
void addEntry (key k, value v)'로'void addEntry (HashEntry (key k, value v))'를 변경 하시겠습니까? –
ildjarn
ildjarn thanks! – Figo