2013-02-13 41 views
1

我寫C++在Visual Studio 2010的代碼,作爲我的初中看起來像視覺聊齋志異行爲

#include <iostream> 
using namespace std; 
int main() 
{ 
    cout<< "How are Your"; 
} 

一個例子,我不明白這個程序是如何構建和沒有,如果任何一個return語句執行我可以爲我解釋一下嗎?

+0

這可能是有用的:http://stackoverflow.com/questions/12376461/what-actually-happens-when-a-function-with-the-warning-control-reaches-end-o – 2013-02-13 12:03:14

回答

9

如果沒有main功能return語句,它的默認return 0;

§3.6.1

在主return語句有離開的主要功能 (破壞任何物體的影響自動存儲持續時間),並以返回值作爲參數調用 std :: exit。如果控制權到達 的末尾而沒有遇到返回語句,則效果爲 即執行返回0;