template and map problem

Hi there,

I am trying to develop a function template as follows:


template <typename Iter> typename Iter::value_type findMost(Iter begin, Iter last) {

typedef typename Iter::value_type vtype;
map<vtype, int> record;
while(begin != last) {
++record[*begin] ;
++begin;
}

map<vtype, int>::iterator mbeg = record.begin();
//
//
return 0;
}

The complier shows ERROR on "map<vtype, int >::iterator mbeg = record.begin();". It says "error: expected ‘;’ before ‘mbeg’" and "error: dependent-name ‘std::map::iterator’ is parsed as a non-type, but instantiation yields a type".

Why there is such an error showing up here? is it because of the key of the map needs to fulfill certain rules?
Topic archived. No new replies allowed.