首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

编译现象疑惑.解决思路

2012-03-14 
编译现象疑惑.~.~.~#includeiostream.hintmain(){intx(10)cout x endlreturn0}刚刚开始学C++,

编译现象疑惑.~.~.~
#include   <iostream.h>

int   main()
{
int   x(10);
cout < <x < <endl;
return   0;
}
刚刚开始学C++,只是个环境测试程序,在g++   -o   1   1.cpp后总会有一大串提示:

In   file   included   from   /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/ios
tream.h:31,
                                  from   1.cpp:1:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/backward_warning.h:32:2:
warning:   #warning   This   file   includes   at   least   one   deprecated   or   antiquated   header.   Please   consider   using   one   of   the   32   headers   found   in   section   17.4.1.2   of   the   C++   standard.   Examples   include   substituting   the   <X>   header   for   the   <X.h>   header   for   C++   includes,   or   <iostream>   instead   of   the   deprecated   header   <iostream.h> .   To   disable   this   warning   use   -Wno-deprecated.

编译能顺利通过,就是有点不爽,那大概意思也明白,就是不晓得怎么做哈,,,赐教.~

[解决办法]
#include <iostream.h> // 提示这种头文件的用法已经不推荐使用了,而应该用#include <iostream>

int main()
{
int x(10);
cout < <x < <endl;
return 0;
}
[解决办法]
完整的是
#include <iostream>
using namespace std;
[解决办法]
的确 的确
[解决办法]
如果真的是学习c++,就按照标准来吧, 就如包含头文件这样的格式问题,标准就说的很清楚了。 呵呵

[解决办法]
#include <iostream>

using namespace std;

int main()
{
int x(10);
cout < <x < <endl;
return 0;
}

或者

#include <iostream>

int main()
{
int x(10);
std::cout < <x < <std::endl;
return 0;
}

[解决办法]
初学,书上怎么说,你就怎么做.

std称为名字空间.
举例说,上海有个 "南京路 ",台北也有个 "南京路 "
两个在上海生活的人谈到 "南京路 ",它们各自都知道是指的 "上海南京路 ",
两个在台北生活的人谈到 "南京路 ",它们各自都知道是指的 "台北南京路 ",
但当一个台北人和一个上海人在巴黎谈论 "南京路 ",如果不加上海或台北限定就会误会,上海人以为在谈 "上海南京路 ",台北人以为在谈 "台北南京路 ".
给 "南京路 "加上的 "上海 "(或 "台北 ")称为 "南京路 "的名字空间,C++语法表示为
上海::南京路
台北::南京路


[解决办法]
两个在上海生活的人谈到 "南京路 ",它们各自都知道是指的 "上海南京路 ",那是因为它们预先加了
using namespace 上海;
[解决办法]
.... <iostream> instead of the deprecated header <iostream.h> .....
[解决办法]
.net下面:
写成
#include "stdafx.h "
#include <iostream>

int _tmain(int argc, _TCHAR* argv[])
{
int x(10);
std::cout < <x < <std::endl;
return 0;
}
是可以的,我刚刚试过了。如果你是VC6.0的话,要用#include "iostream.h "



[解决办法]
还是用.net吧,在windows下面,这个编译器还是不错的。
[解决办法]
楼主选择的C++书太老了
那些书的说法还是C++刚出来时候的样子,和目前的标准相差甚远了。。。

推荐 Thinking in C++ V3(or V4)

热点排行