LinuxSir.cn,穿越时空的Linuxsir!

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

[请教]这个hello例子G++编译有问题,是什么问题?

[复制链接]
发表于 2004-12-14 16:45:01 | 显示全部楼层 |阅读模式
code
#inlude<iostream>
int main()
{ cout<<"good\n";
return 0;
}
/code

[root@dale root]# g++ test2.cpp -o q
test2.cpp:1:2: invalid preprocessing directive #inlude
test2.cpp: In function `int main()':
test2.cpp:4: `cout' undeclared (first use this function)
test2.cpp:4: (Each undeclared identifier is reported only once for each
   function it appears in.)
错误是在说头文件有问题?到底如何改正,谢谢各位了
发表于 2004-12-14 16:51:56 | 显示全部楼层
search旧贴。。
发表于 2004-12-14 17:15:32 | 显示全部楼层
  1. using namespace std;
复制代码
发表于 2004-12-14 17:59:28 | 显示全部楼层
除了楼上说的,还要在

#inlude<iostream>

的第二个字母 n 和第三个字母 l 之间加一个字母 c

变成 #include <iostream>

:%
 楼主| 发表于 2004-12-14 21:19:31 | 显示全部楼层
不好意思
 楼主| 发表于 2004-12-15 09:56:49 | 显示全部楼层
我找了一下旧帖没看到啊,那个name space是什么意思,我是菜鸟,不好意思
发表于 2004-12-15 15:08:14 | 显示全部楼层
就是C++中的名字空间,一般的C++教材上应该有介绍。
 楼主| 发表于 2004-12-15 17:24:35 | 显示全部楼层
决定好好看书,谢谢各位了。
kj501斑斑,很佩服你,我看了这个版以前得帖子,发现kj501好热心,机会逢帖必回
发表于 2004-12-15 18:55:19 | 显示全部楼层
这样会累死斑竹的,还是多看看自己的代码和书吧,不行还可以
google
发表于 2004-12-15 19:06:30 | 显示全部楼层
最初由 eddy 发表
这样会累死斑竹的,还是多看看自己的代码和书吧,不行还可以
google

虽然辛苦点,但还不至于累死人吧,呵呵。。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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