해시 테이블을 쓰고 있지만 어려움에 직면했습니다.
map <string,int> m(a.begin(),a.end())
다음과 같은 클래스 정의가 있습니다 : template <class key,class val,class hashik=std_hash> class hash_table
. 다음과 같은 클래스 정의가 있습니다.
은 내가 생성자 정의 :STL 반복자를 사용하는 템플릿 생성자
template <template <class> class C> hash_table(typename C<pair <key,val> >::iterator first,typename C<pair <key,val> >::iterator last)
{
init();
for(pair <key,val>* it=first;it!=last;++it)
this->operator[](it->first)=it->second;
}
를하지만 컴파일되지 않습니다. 통화와 일치하는 기능이 없습니다. 예 :
vector <pair <string,int> > a;
...
hash_table <string,int> m(a.begin(),a.end()); //compilation error
내가 뭘 잘못하고 있니? 그리고 템플릿에 관한 어떤 책을 읽으라고 조언 할 수 있습니까?
다른 사람이 컴파일을 시도 할 수있는 [예제] (http://www.sscce.org/)를 게시 할 수 있습니까? – Praetorian