我有以下代碼:類型名稱路徑是由一個靜態變量隱藏
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