2
當我無意中寫道:嵌套函數被禁用 - 爲什麼我會收到此錯誤消息?
UIViewController tmp*=_currentViewController;
相反的:
UIViewController *tmp=_currentViewController;
我得到一個嵌套函數被禁用錯誤。你能解釋一下嗎?
當我無意中寫道:嵌套函數被禁用 - 爲什麼我會收到此錯誤消息?
UIViewController tmp*=_currentViewController;
相反的:
UIViewController *tmp=_currentViewController;
我得到一個嵌套函數被禁用錯誤。你能解釋一下嗎?
你可能已經意識到了這一點,但這樣的:
UIViewController tmp*=_currentViewController;
被解釋爲:
UIViewController tmp *= _currentViewController;
這是一個分配的乘法運算與LHS是對象的聲明(非 - 指針)名爲「tmp」。名爲「_currentViewController」的對象指針是另一個操作數。
因此,這個簡單的說法得到了同樣的錯誤:
int a *= b;
通常你必須是這樣的:
a *= b;
它擴展爲:
a = a * b;
然而,LHS在這種情況下不是簡單的「a」,而是聲明「int a」。
我的猜測是,由於這種怪異的LHS值,編譯器解釋的這個擴張是這樣的:
int a { return a * b; }
這顯然是一個nested function。