3
#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;
}
이 코드는 컴파일되지 않으며 오류의 원인을 파악할 수 없습니다. 어떤 도움을 주시면 감사하겠습니다. 감사!종속 범위 오류 stl
는 오류가
error: need ‘typename’ before ‘std::map<T, double>::iterator’ because ‘std::map<T, double>’ is a dependent scope
에 나는 오류가 당신에게 아주 좋은 힌트 –
'하면 것은 (...) false를 돌려주고있다 생각; 그렇지 않으면 true를 반환하고, '는 반 패턴입니다. 대신'return not ...;'를 써라. –
그 대회를 지적 해 주셔서 감사합니다. 그것을 사용하게됩니다 ... – shashydhar