#include <iostream>
#include <map>
#include <string>
using namespace std;
template <class T>
class Counter
{
public:
Counter()
{
totalCount
}
~Counter()
{
}
bool containsKey(T key)
{
map<T, double>::iterator it = counter.find(T);
if (it == counter.end()) return false;
return true;
}
private:
map<T, double> counter;
double totalCount;
};
int main()
{
Counter<string> table;
return 0;
}
这段代码甚至没有编译,我不知道是什么错误。任何帮助,将不胜感激。谢谢!
cmd编译
g++ counter.cpp
错误是
error: need ‘typename’ before ‘std::map<T, double>::iterator’ because ‘std::map<T, double>’ is a dependent scope