我剛開始學習C++,針對的主要方法我做的:返回從主管道破裂我的程序零
#include <iostream>
using namespace std;
int main()
{
int d;
int n;
cout <<"Enter the denominator: " << endl;
cin >> d;
cout <<"Enter the numerator: " << endl;
cin >> n;
cout <<"The result of operation is: " << endl;
cout << (double)n/d << endl;
cout <<"Done";
return 0;
}
它不會產生輸出,但如果我刪除返回0,我會產生正確的輸出。 C++中的主要方法不應總是返回一個整數嗎?
它適合我。 – icktoofay 2013-05-14 01:56:50
函數'main'是一個特殊情況,因爲那裏(並且只有那裏)不必是'return'語句,即使該函數返回一個'int'。如果沒有顯式的'return'語句,則返回'0'。 [basic.start.main]/5 – dyp 2013-05-14 01:57:40
請參閱[這個問題](http://stackoverflow.com/q/636829/335858)討論'main()'應該返回的內容。 – dasblinkenlight 2013-05-14 01:59:01