<分区>
Possible Duplicate:
Where and why do I have to put the “template” and “typename” keywords?
map iterator in template function unrecognized by compiler
我有一个模板函数,其中有 std::map::iterator
实例化 -
template <class B , class C>
C getValue (B& myMap , C returnType) {
map<string,C>::iterator it = myMap.find(var);
// implementation ...
}
并提示错误——
In function ‘C getValue(char*, B&, C)’:
error: expected ‘;’ before ‘it’
error: ‘it’ was not declared in this scope
我应该如何正确制作它?