程序只有一个文件,包涵一个模板类,编译粗提示错误:
main.cpp:17: error: expected ';' before 'myit'
我用的是QT Creator 2.3.1 MinGw for windows
源文件如下:
//------------------------------------------------------------
//------------------------------------------------------------
#include <QtCore/QCoreApplication>
#include <map>
template <class T>
class MySetting
{
public:
void function();
private:
T m_data;
};
////////////////////////////////////////////////////////////////////////
template <class T>
void MySetting<T>::function()
{
std::map<int, T*>::iterator myit; //编译提示出错 error: expected ';' before 'myit'
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}
//----------------------------------