﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-wsgyj-随笔分类-C++</title><link>http://www.cppblog.com/wsgyj/category/11762.html</link><description /><language>zh-cn</language><lastBuildDate>Mon, 21 Sep 2009 10:14:23 GMT</lastBuildDate><pubDate>Mon, 21 Sep 2009 10:14:23 GMT</pubDate><ttl>60</ttl><item><title>关于VC中  error C2871: 'std' : does not exist or is not a namespace</title><link>http://www.cppblog.com/wsgyj/archive/2009/09/20/96795.html</link><dc:creator>gyj</dc:creator><author>gyj</author><pubDate>Sun, 20 Sep 2009 13:41:00 GMT</pubDate><guid>http://www.cppblog.com/wsgyj/archive/2009/09/20/96795.html</guid><wfw:comment>http://www.cppblog.com/wsgyj/comments/96795.html</wfw:comment><comments>http://www.cppblog.com/wsgyj/archive/2009/09/20/96795.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wsgyj/comments/commentRss/96795.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wsgyj/services/trackbacks/96795.html</trackback:ping><description><![CDATA[<p>今天写了个程序用了如下代码</p>
#include &lt;iostream.h&gt;<br>using namespace std;<br>然后编译时出现&nbsp; error C2871: 'std' : does not exist or is not a namespace<br><br>查了一下，原来 C++有两个不同版本的头文件。引入名字空间这个概念以前编译器用的是#include &nbsp; &lt;iostream.h&gt;，<br>而引入名字空间的概念以后std名字空间的头文件名字变成了&lt;iostream&gt;。<br><br>&lt;iostream.h&gt;是比较老的C++的头文件的版本，而namespace是98年才被加入C++标准的，所以&lt;iostream.h&gt;里面是没有std这么个命名空间的，当使用 &lt;iostream.h&gt;时，相当于在c中调用库函数，使用的是全局命名空间，也就是早期的c++实现。头文件&lt;iostream&gt;则没有定义全局命名空间，使用时必须使用namespace std才能正确使用cout。<br><br>&nbsp; vc6.0支持这个两个版本.&nbsp;不过现在都用&lt;iostream&gt;了&nbsp;&nbsp; <br><br>所以只需将以上语句改为：<br>#include &lt;iostream&gt; <br>using namespace std;<br>或者是&nbsp; #include &lt;iostream.h&gt;即可。<br>
<img src ="http://www.cppblog.com/wsgyj/aggbug/96795.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wsgyj/" target="_blank">gyj</a> 2009-09-20 21:41 <a href="http://www.cppblog.com/wsgyj/archive/2009/09/20/96795.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>