2 回答

TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超9個(gè)贊
哎 寫(xiě)了那么多
結(jié)果沒(méi)發(fā)表出來(lái) 郁悶
現(xiàn)在大概說(shuō)下
給你2個(gè)改好了的程序
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";
}
錯(cuò)誤解釋
錯(cuò)誤1:
:\My Documents\我的資料\VC++\2_1B\2_1B.CPP(2) : error C2871: 'std' : does not exist or is not a namespace
這里相當(dāng)
#include <iostream.h>與
#include <iostream>
using namespace std;等效
錯(cuò)誤2:E:\My Documents\我的資料\VC++\2_1B\2_1B.CPP(7) : warning C4508: 'main' : function should return a value; 'void' return type assumed
執(zhí)行 cl.exe 時(shí)出錯(cuò).
int main()是需要return 0;這個(gè)語(yǔ)句的
而void main()不需要
ANIS C++標(biāo)準(zhǔn)有了新的規(guī)定,要求主函數(shù)為int類型,如果程序正常執(zhí)行則返回0值;系統(tǒng)頭文件不帶后綴.h;使用系統(tǒng)庫(kù)時(shí)使用命名空間std;
- 2 回答
- 0 關(guān)注
- 906 瀏覽
添加回答
舉報(bào)