最近有朋友问了一下C++中的这个问题,我把它记录下来了,供大家分享和交流!
#include <iostream>
...
std::cout << ...
或者
#include <iostream>
using namespace std;
cout << ...
这样写就是正确的,在程序的开头加入以下代码:
using namespace std;
这样就不用在程序体内加入很多的std::这样的域运算符了.
在VC++中如果
#include "iostream.h"
.....
std::out<<........
就会报错error C2653: 'std' : is not a class or namespace name
旧标准是:<iostream.h> 不必using namespace std;
新标准是:<iostream> 要有using namespace std;
iostream.h里没有std空间,只有iostream里有