【发布时间】:2013-10-03 10:45:34
【问题描述】:
我有以下源代码,用 MinGW 编译。但是当我尝试构建时,我遇到了编译类型错误:
main.cpp:11: error: expected type-specifier
using Iter = MyMap::iterator;
^
main.cpp:12: error: expected type-specifier
using CIter = MyMap::const_iterator;
^
GCC 期望在 MyMap 之前有一个说明符。但它期望哪个说明符?
#include <ctime>
#include <map>
template< typename T >
class MyClass
{
private:
class Inner {};
using MyMap = std::map< time_t, Inner >;
using Iter = MyMap::iterator;
using CIter = MyMap::const_iterator;
};
int main()
{
return 0;
}
【问题讨论】:
-
您可能想阅读this old answer。
-
非常感谢。我会仔细阅读的
-
我的印象是这个问题每天在 SO 上出现好几次。然而,我没能找到一个好的副本。也许这是因为症状可能完全不同(症状就是问题标题的全部内容)?
标签: c++ c++11 compiler-errors