尽管下面的示例编译得很好,除了最后一行有错误,我想知道这个“范围”在一个范围内的来龙去脉?还有这个的术语,如果有的话。
考虑这些括号:
void func()
{
int i = 0;
{ // nice comment to describe this scope
while( i < 10 )
++i;
}
{ // nice comment to describe this scope
int j= 0;
while( j< 10 )
++j;
}
i = 0; // OK
// j = 0; // error C2065
}
考虑一下:
error C2065: 'j' : undeclared identifier
编辑: 接受的答案来自bitmask,尽管我认为每个人都应该将它放在anio 's answer的上下文中。特别是,引用:“也许你应该把你的功能分成两个功能”