LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 929|回复: 5

唉!又有问题了,向大家请教!!多谢了,多谢了!!(gcc编译c++)

[复制链接]
发表于 2008-12-10 16:11:17 | 显示全部楼层 |阅读模式
源文件是:test.cpp
  1. #include <iostream.h>
  2. void main()
  3. {
  4. double r,girth,area;
  5. const double PI=3.1415;
  6. cout<<"Please input radius:\n";
  7. cin>>r;
  8. girth=2*PI*r;
  9. area=PI*r*r;
  10. cout<<"radius="<<r<<endl;
  11. cout<<"girth="<<girth<<endl;
  12. cout<<"area="<<area<<endl;
  13. }
复制代码

编译命令是:
$ gcc -o test test.cpp

然后就输出了如下的一堆错误!
  1. In file included from /usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/backward/iostream.h:31,
  2.                  from test.cpp:1:
  3. /usr/lib/gcc/x86_64-linux-gnu/4.1.2/../../../../include/c++/4.1.2/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.
  4. test.cpp:2: error: ‘::main’ must return ‘int’
复制代码
使用命令:
$ g++ -o test test.cpp
也出现同样的错误!!天啊!!!!!!我怎么这么笨啊!!



在此先感谢了,我知道我的问题可能很愚蠢,但是我不会呀,我也没办法!!唉!!!!!!!!!
很无奈!!!!
发表于 2008-12-10 17:44:13 | 显示全部楼层
是不是最后要加“return 0;”啊?
还有“void main ()”能在linux下用吗?
我乱说的...
回复 支持 反对

使用道具 举报

发表于 2008-12-10 21:04:05 | 显示全部楼层
改成 int main(),函数结尾 return 0;
回复 支持 反对

使用道具 举报

发表于 2008-12-10 21:42:30 | 显示全部楼层
你需要的是一本符合C++标准的书
回复 支持 反对

使用道具 举报

发表于 2008-12-11 04:18:15 | 显示全部楼层
還需要學一點英語
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-12-11 17:57:09 | 显示全部楼层
Post by zlbruce;1922223
你需要的是一本符合C++标准的书


xie xie
wo zhongyu zhidao le ,
wo de tian a!!!!
xie xie le
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表