maple3142
V2EX  ›  问与答

能夠在 c++裡呼叫 main()?

  •  
  •   maple3142 · Oct 31, 2016 · 2020 views
    This topic created in 3483 days ago, the information mentioned may be changed or developed.
    int main(){
    //一些代碼
    return main();
    }
    c++能夠這樣呼叫嗎?
    amaranthf
        1
    amaranthf  
       Oct 31, 2016
    可以,不过如果“一些代码”没有其他的退出条件的话,这个程序将无限循环,同时如果编译器没有进行尾递归优化的,这个无限循环将在执行一定次数之后造成栈溢出崩溃。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2986 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 398ms · UTC 12:52 · PVG 20:52 · LAX 05:52 · JFK 08:52
    ♥ Do have faith in what you're doing.