main()函数在C ++中调用自身,会发生什么? [英] main() function calls itself in C++, what will happen?
本文介绍了main()函数在C ++中调用自身,会发生什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include <iostream>
int main()
{
main();
std::cout<<"Hello World! "<<std::endl;
return 0;
}
这是代码,它是怎么样的?为什么?
This is the code, How does it behave? Why?
推荐答案
这是未定义的行为。你不能在C ++程序中调用main()(标准的第3.6.1.3节)。
That's undefined behaviour. You cannot call main() from within a C++ program (section 3.6.1.3 of the standard).
因此,任何事情都可能发生。没有必要问为什么。
Therefore anything can happen. And there's no point in asking why.
这篇关于main()函数在C ++中调用自身,会发生什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文