#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>就可以。

error C2871: &#39;std&#39; : does not exist or is not a namespace的更多相关文章

  1. 解决Eclipse中C++代码显示Symbol &#39;std&#39; could not be resolved的问题

    第一次在Eclipse中写C++代码,写了一个简单的hello world程序,还没有等我编译.就报出了各种错误,但是这么简单的代码.怎么可能这么多错误.于是没有理会.编译执行后,能够正常输出!!!H ...

  2. 【gradle报错】error: package org.apache.http does not exist

    导入项目的时候gradle报错 error: package org.apache.http does not exist 解决方法: 在build.gradle中加入 android {   use ...

  3. Error resolving template [xxx], template might not exist or might not be exist

    Springboot+thymeleaf+mybatis 抛Error resolving template [xxx], template might not exist的异常 原因是我们在pom. ...

  4. Error 2 error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)'

    Error 2 error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree ...

  5. Error resolving template: template might not exist or might not be accessible是一句缩水报错?

    一 thymeleaf在开发的时候本地调试正常,但是在测试环境打成jar包就报这个错误了. 二 template might not exist or might not be accessible ...

  6. role &#39;PLUSTRACE&#39; does not exist

    I have created a new user named watson and granted the related priviledges as following: SQL> cre ...

  7. error: &#39;for&#39; loop initial declarations are only allowed in C99 mode

    error: 'for' loop initial declarations are only allowed in C99 mode 使用gcc编译代码是报出 error: 'for' loop i ...

  8. Error creating bean with name &#39;menuController&#39;: Injection of autowired dependency……

    出现了一大串错误 Error creating bean with name 'userController': Injection of autowired dependencies failed. ...

  9. Error creating bean with name &#39;memcachedClient&#39;...java.lang.OutOfMemoryError

    1,Tomcat启动报错例如以下: Caused by: org.springframework.beans.factory.BeanCreationException: Error creating ...

随机推荐

  1. 异常学习笔记+打包+doc该软件包编译

    jvm调用默认的异常处理机制printStackTrace办法      欲了解更多异常处理.问题      捕获异常代码块出现继承关系 应该把被继承的异常放在子类异常块的后面 watermark/2 ...

  2. Bitmap

    Bitmap篇   在前一篇中介绍了使用API做Distinct Count,但是计算精确结果的API都较慢,那有没有能更快的优化解决方案呢? 1. Bitmap介绍 <编程珠玑>上是这样 ...

  3. TextBox自定义Mac输入框类

    using System.Windows.Controls; namespace test { public class MacTextBox : TextBox { private string _ ...

  4. sitemap.xml

    内部类  在类内部的类 1.解决多继承 2.解决继承和实现接口时候方法名冲突情况 3.实现数据隐藏 只有内部类可以拥有4种访问修饰符 当内部类为private的时候,有外部类提供方法来访问内部类 常规 ...

  5. MVC的DependencyResolver组件

    MVC的DependencyResolver组件 一.前言 DependencyResolver是MVC中一个重要的组件,从名字可以看出,它负责依赖对象的解析,可以说它是MVC框架内部使用的一个IOC ...

  6. 【原创】最近写的一个比较hack的小爬虫

    目标:爬取爱漫画上面自己喜欢的一个漫画 分析阶段: 0.打开爱漫画主页,迎面就是一坨js代码..直接晕了 1.经过抓包和对html源码的分析,可以发现爱漫画通过另外一个域名发送图片,而当前域名中通过j ...

  7. C++0x新特性

    我是在一个帖子上摘抄的大神语录...感谢supermegaboy大神,给了详尽的解释 下文是一篇转载的Wikipedia的译文,从语言和库双方面概述了C++0x. 右值引用与转移语义 在标准C++语言 ...

  8. hdu - 4975 - A simple Gaussian elimination problem.(最大流量)

    意甲冠军:要在N好M行和列以及列的数字矩阵和,每个元件的尺寸不超过9,询问是否有这样的矩阵,是独一无二的N(1 ≤ N ≤ 500) , M(1 ≤ M ≤ 500). 主题链接:http://acm ...

  9. JAVA先进-设置(1)

    >Arrays 基本阵列 1.常见的数组产生于main() 函数,数组下标的索引不能超过0到int的范围 2.当程序试图訪问数组的第一个或者最后一个数据的时候,会发生ArrayIndexOutO ...

  10. [ACM] POJ 3687 Labeling Balls (拓扑排序,反向生成端)

    Labeling Balls Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10161   Accepted: 2810 D ...