【发布时间】:2012-03-02 12:59:19
【问题描述】:
我正在将一个项目从 Visual Studio 6 转换为 Visual Studio 2010。该项目大量使用 STL。有一个自定义类,它的子类列表可以添加更多方法。以下是我得到的代码和编译器错误。
#include <list>
namespace mySpace
{
template <class T>
class MyList : public std::list<T>
{
...
};
template <class T>
MyList<T>::reference MyList<T>::find(const_reference p_constreferenceItem) const
{
return std::find(this->begin(), this->end(), p_constreferenceItem);
}
} // namespace mySpace
错误:
Error 2 error C2143: syntax error : missing ';' before 'MySpace::MyList<T>::find' c:\myproject\mylist.h 300 1
Error 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\myproject\mylist.h 300 1
Error 4 error C2888: 'MyList<T>::reference reference' : symbol cannot be defined within namespace 'MySpace' c:\myproject\mylist.h 300 1
任何想法是什么导致了这个错误?
【问题讨论】:
标签: c++ visual-studio list stl