【发布时间】:2009-03-19 08:54:23
【问题描述】:
以下代码在声明迭代器的行生成语法错误:
template <typename T>
class A
{
public:
struct B
{
int x, y, z;
};
void a()
{
std::map<int, B>::const_iterator itr; // error: ; expected before itr
}
std::vector<T> v;
std::map<int, B> m;
};
仅当 A 是模板类时才会发生这种情况。这段代码有什么问题?如果我将 B 从 A 中移出,代码编译得很好。
【问题讨论】:
标签: c++ templates nested stdmap