关于VC中 error C2871: 'std' : does not exist or is not a namespace
来源:互联网 发布:韩国打榜用什么软件 编辑:程序博客网 时间:2024/06/07 10:39
#include <iostream.h>
using namespace std;
然后编译时出现 error C2871: 'std' : does not exist or is not a namespace
查了一下,原来 C++有两个不同版本的头文件。引入名字空间这个概念以前编译器用的是#include <iostream.h>,
而引入名字空间的概念以后std名字空间的头文件名字变成了<iostream>。
<iostream.h>是比较老的C++的头文件的版本,而namespace是98年才被加入C++标准的,所以<iostream.h>里面是没有std这么个命名空间的,当使用 <iostream.h>时,相当于在c中调用库函数,使用的是全局命名空间,也就是早期的c++实现。头文件<iostream>则没有定义全局命名空间,使用时必须使用namespace std才能正确使用cout。
vc6.0支持这个两个版本. 不过现在都用<iostream>了
所以只需将以上语句改为:
#include <iostream>
using namespace std;
或者是 #include <iostream.h>即可。
using namespace std;
然后编译时出现 error C2871: 'std' : does not exist or is not a namespace
查了一下,原来 C++有两个不同版本的头文件。引入名字空间这个概念以前编译器用的是#include <iostream.h>,
而引入名字空间的概念以后std名字空间的头文件名字变成了<iostream>。
<iostream.h>是比较老的C++的头文件的版本,而namespace是98年才被加入C++标准的,所以<iostream.h>里面是没有std这么个命名空间的,当使用 <iostream.h>时,相当于在c中调用库函数,使用的是全局命名空间,也就是早期的c++实现。头文件<iostream>则没有定义全局命名空间,使用时必须使用namespace std才能正确使用cout。
vc6.0支持这个两个版本. 不过现在都用<iostream>了
所以只需将以上语句改为:
#include <iostream>
using namespace std;
或者是 #include <iostream.h>即可。
0 0
- 关于VC中 error C2871: 'std' : does not exist or is not a namespace
- 关于VC中 error C2871: 'std' : does not exist or is not a namespace
- 关于VC中 error C2871: 'std' : does not exist or is not a namespace
- 关于VC中 error C2871: 'std' : does not exist or is not a namespace
- 关于VC中 error C2871: 'std' : does not exist or is not a namespace
- 关于error C2871: 'std' : does not exist or is not a namespace处理
- 关于error C2871: ''std'' : does not exist or is not a namespace处理
- error C2871: 'std' : does not exist or is not a namespace
- C++ 编译出现: error C2871: 'std' : does not exist or is not a namespace 怎么解决
- error C2871: 'std' : does not exist or is not a namespace
- error C2871: 'std' : does not exist or is not a namespace
- error C2871: 'System' : a namespace with this name does not exist
- Error starting static Resources:* does not exist or is not a readable directory
- does not exist or is not a readable directory
- ..\TestApp does not exist or is not a readable directory
- Error: ‘shared_ptr’ in namespace ‘std’ does not name a type
- netbean中does not exist or is not a readable错误的解决
- netbean中does not exist or is not a readable错误的解决
- html字符转义
- 日期的操作类
- java线程的生命周期
- 如果你喜欢上了一个程序员小伙,献给所有的程序员女友
- InnoDB体系架构简介
- 关于VC中 error C2871: 'std' : does not exist or is not a namespace
- 集合栈计算机
- SUSE HA的安装
- 计数排序
- Unity中各种常用文件夹的用处
- 源码解读Spring IOC原理
- 字符串匹配——KMP算法
- ZOJ 3228 Searching the String (AC自动机)
- addEventListener 的用法示例介绍(转)