本文介紹了在 C++ 中遞歸到 main() 是否合法?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我讀到 C++ 標(biāo)準(zhǔn)禁止 main()
中的遞歸,但是 g++ 編譯了以下代碼而沒有抱怨:
I read that the C++ standard forbids recursion in main()
, but g++ compiles the following code without complaint:
int main()
{
main();
}
有人能澄清一下嗎?
推薦答案
按照3.6.1/3的標(biāo)準(zhǔn),不是:
According to the standard in 3.6.1/3, it's not :
函數(shù)main
不得使用(3.2) 在程序內(nèi)
used 的定義是:
一個對象或非重載如果函數(shù)名稱出現(xiàn)在潛在求值表達(dá)式中,則使用該函數(shù).
An object or non-overloaded function is used if its name appears in a potentially-evaluated expression.
這篇關(guān)于在 C++ 中遞歸到 main() 是否合法?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!