我有一个简单的函数要检查一个值是否在列表中 :
template <class T>
bool IsinList(list<T> l, T x)
{
for(list<T>::iterator it=list.begin(); it != list.end(); it++)
{
if (*it == x)
return true;
}
return false;
}
我在相同的.cpp 文件中使用了这样的函数 :
if (!IsinList (words, temp))
goodwords.push_back(temp);
但我得到这个错误:
std::list : use of class template requires template argument list
and I cant figure out what the problem is. I checked in previous asked questions and it didn t help. Can you explain to me what am I doing wrong?