我有以下代码:类型名称路径是由一个静态变量隐藏
struct type1
{
struct type2
{
};
int tyep2; // No conflic with real type name path: type1::type2
};
struct type4
{
struct type5
{
};
static int type5; // No conflic with real type name path: type4::type5
};
int type4::type5; // this path name is equal to type name path: struct type4::type5
int _tmain(int argc, _TCHAR* argv[])
{
type1::type2 var1; // is ok
type4::type5 Var2; // is ok
type4::type5 = 0; // is ok, but the static variable has obscured my type
return 0;
}
我的问题是:
- 为什么静态变量成的Type5隐藏式 type4 :: type5
- 为什么编译呃当我声明type5时不会产生错误变量?
- 在哪里可以阅读有关C++标准规范中的这种行为?请发表最终的提取物
对不起,我发布了一个错误代码 – AngeloDM 2015-02-10 21:54:54
为什么你说“静态变量已经模糊了你的类型”? – 2015-02-10 22:56:38