免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1361 | 回复: 7
打印 上一主题 下一主题

问一很菜的问题,请帮忙 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-10-17 12:52 |只看该作者 |倒序浏览
我的G++怎么编不了.cpp文件,我就写了简单的helloword的文件,出错如下
[root@localhost c++]# g++ -o hello hello.cpp
hello.cpp:3: error: `main' must return `int'
hello.cpp: In function `int main(...)':
hello.cpp:4: error: `cout' undeclared (first use this function)
hello.cpp:4: error: (Each undeclared identifier is reported only once for each
   function it appears in.)
hello.cpp:4: error: `endl' undeclared (first use this function)
hello.cpp:5:2: warning: no newline at end of file

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
2 [报告]
发表于 2006-10-17 12:57 |只看该作者
#include <iostream>
using namespace std;
你的教材上没有这个吗?

论坛徽章:
0
3 [报告]
发表于 2006-10-17 13:02 |只看该作者
一直在写C,一下子写C++有点蒙了,希望赐教一下,急!!

论坛徽章:
0
4 [报告]
发表于 2006-10-17 13:09 |只看该作者

贴源代码

#include <iostream.h>

或者是

#include<iostream>
using namespace  std

论坛徽章:
0
5 [报告]
发表于 2006-10-17 13:12 |只看该作者
对不起,早就试过了,没用!!
请帮忙,急急急!!!

论坛徽章:
0
6 [报告]
发表于 2006-10-17 14:16 |只看该作者
1.main函数没有返回int型数据;
2.好像没有包含某个头文件或没有使用命名空间std.
3.源文件最后没有空行.

论坛徽章:
0
7 [报告]
发表于 2006-10-17 15:02 |只看该作者
楼主怎么连source code都不贴出来。也不说g++版本。

论坛徽章:
0
8 [报告]
发表于 2006-10-17 17:18 |只看该作者
#include<iostream>
using namespace std;
main()
{
  cout<<"hello world"<<endl;

}

一点问题没有,你有没去试啊,???
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP