I made a histogram class and wanted to test it, but I'm getting errors like this:
which is this line:Code:303 C:\Dev-Cpp\Projects\Histography\main.cpp instantiated from here
cout << hist.get_most_num_occurances();
Not sure.Code:101 C:\Dev-Cpp\Projects\Histography\main.cpp 'struct std::_Rb_tree_iterator<std::pair<const char, int> >' has no member named 'begin'
The main method looks like this:
The bold line is what gives the error.Code:int main() { map<char, int> my_map; my_map.insert( make_pair('a',2) ); my_map.insert( make_pair('b',3) ); my_map.insert( make_pair('c',1) ); Histogram<char> hist(my_map); cout << hist.get_most_num_occurances(); getchar(); }
This is the function:
Code:template <typename T> int Histogram<T>::get_most_num_occurances() { typename map<T,int>::iterator ci; int high = ci.begin(); for (ci=frequency.begin(); ci != frequency.end(); ++ci) { if (ci->second > high) { high = ci->second; } } }
Can anyone spot the problem? I've been beating my head on this one and can't figure it out.




Reply With Quote