I'm having trouble iterating through an std::map I've constructed for a template Counter class. The class is entirely defined in a file called "Counter.h" because I read you should implement whole template classes in the header file, and I was having problems splitting functionality into a .cpp. The pertinent areas of "Counter.h" go something like...
//File: Counter.h
template class<T> class Counter {
public:
void foo() {
class map<T,size_t>::iterator it; //PROBLEM IS HERE.
for (it = counts.begin(); it != counts.end; it++) {
//Do map stuff.
}
}
private:
map<T,size_t> counts;
}
However, the declaration of the iterator throws the following error:
error: elaborated type refers to a typedef
class map<T,size_t>::iterator mapIt;
^
I'm having trouble wrapping my head around this. Any ideas?