【求救】MS VC 能编译,gcc 报错,为何?
keios 2006-03-28 05:34:29 #include <list>
template<class T>
bool my_find(std::list<T *> *pList, const T* val)
{
for (std::list<T *>::iterator it = pList->begin(); it != pList->end(); ++it)
{
if (*it == val)
return true;
}
return false;
}
int main()
{
return 0;
}
---------------------------------------------------------------------
以上代码,使用微软VS 2003 能够顺利编译通过,但是使用 gcc 3.4.5 却报错:
test1.cpp: In function `bool my_find(std::list<T*, std::allocator<T*> >*, const T*)':
test1.cpp:6: error: expected `;' before "it"
test1.cpp:6: error: `it' undeclared (first use this function)
test1.cpp:6: error: (Each undeclared identifier is reported only once for each function it appears in.)
请问如何修改代码使其在 gcc 下不报错?