看以下2段最简单的code:
//第一段,注意#include。
#include <iostream>
using namespace std;
void main()
{
cout << " Your charset is : " << endl;
char s;
cin >> s;
cout << s << endl;
}
//****************************************************************
//第一段使用VC++ 6编译没有问题,第二段使用VC++ 6编译报错:
//D:\CPPs\cpp1.cpp(2) : error C2871: std : does not exist or is not a namespace
//
//第二段,注意#include。
#include <iostream.h>
using namespace std;
void main()
{
cout << " Your charset is : " << endl;
char s;
cin >> s;
cout << s << endl;
}
//****************************************************************
//第一段使用VC++ 6编译没有问题,第二段使用VC++ 6编译报错:
//D:\CPPs\cpp1.cpp(2) : error C2871: std : does not exist or is not a namespace
//
iostream.h这个头文件里面根本就没有namespace这个名字空间
iostream里面才有。
就是兩個頭文件包含的內容不同馬!
faint!!
引入名字空间后的头文件好像都没有.h了!