下面的代码在声明迭代器的行生成语法错误:
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;
};
Run Code Online (Sandbox Code Playgroud)
这只有在A是模板化类时才会发生.这段代码出了什么问题?如果我将B移出A,代码编译得很好.