问题:
网上解决方案:
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文件,我之前因为一个工程的原因,把部分代码注释掉了。。。。(无语中)
取消注释就好了。
本文介绍了一个关于 C++ 中 iostream 使用时遇到的问题及解决过程。问题出现在使用 cout 和 endl 时,错误源于 iostream 文件的部分代码被误注释掉。通过取消注释并调整包含库的顺序解决了问题。

1万+

被折叠的 条评论
为什么被折叠?



