2 回答
TA貢獻1784條經驗 獲得超9個贊
哎 寫了那么多
結果沒發表出來 郁悶
現在大概說下
給你2個改好了的程序
1:#include <iostream>
using namespace std;
int main()
{
cout<<"Hello!\n";
cout<<"Welcome to C++!\n";
return 0;
}
2.#include <iostream.h>
int main()
{
cout<<"Hello!\n";
cout<<"Welcome to C++!\n";
}
錯誤解釋
錯誤1:
:\My Documents\我的資料\VC++\2_1B\2_1B.CPP(2) : error C2871: 'std' : does not exist or is not a namespace
這里相當
#include <iostream.h>與
#include <iostream>
using namespace std;等效
錯誤2:E:\My Documents\我的資料\VC++\2_1B\2_1B.CPP(7) : warning C4508: 'main' : function should return a value; 'void' return type assumed
執行 cl.exe 時出錯.
int main()是需要return 0;這個語句的
而void main()不需要
ANIS C++標準有了新的規定,要求主函數為int類型,如果程序正常執行則返回0值;系統頭文件不帶后綴.h;使用系統庫時使用命名空間std;
- 2 回答
- 0 關注
- 928 瀏覽
添加回答
舉報
