error C2065: 'cout' : undeclared identifier

問題:
C2065問題

網上解決方案:
1.沒有加

#include <iostream>
using namespace std;

or
2.包含的庫的順序需要調整一下

//These will not work.
#include <iostream>
using namespace std;
int main () {
    cout << "hey" << endl;
    return 0;
}
#include <iostream>
#include "stdafx.h"
using namespace std;
int main () {
    cout << "hey" << endl;
    return 0;
}
//This will do.

#include "stdafx.h"
#include <iostream>
using namespace std;
int main () {
    cout << "hey" << endl;
    return 0;
}

最終解決方法:我自己的原因(笑。。。orz)
打開iostream文件,我之前因爲一個工程的原因,把部分代碼註釋掉了。。。。(無語中)
取消註釋就好了。
原因

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章