C++中为了避免名字定义冲突,特别引入了“名字空间的定义”,即namespace。
当代码中用<iostream.h>时,输出可直接引用cout<<x;
//<iostream.h>继承C语言的标准库文件,未引入名字空间定义,所以可直接使用。
使用<iostream>时,引入std::有以下方法:
1.
using namespace std;
cout<<x;
==========================================
stdio.h是C语言的东西,输入输出是这样的printf(...);,scanf(...);
iostream.h是C++的东西,输入输出是这样的cout<<....;,cin>>.....;
在VC6里,头文件写为
#include<iostream.h>
在新的标准库使用时,需要如下所示:
#include<iostream>
using namespace std;
问题在使用CodeLite V9.0.3时使用g++编译器发现。