CX-Post:你好世界 [英] CX-Post: hello world
问题描述
我一定不能在这里抓到任何东西。
只是一个简单的应用程序,如下(任何第一个程序都是......)
----
#include< iostream.h>
int main(){
cout< ;<" hello world";
返回0;
}
----
永远不会编译!在FreeBSD,OpenBSD,Windows(在Visual C ++下用于
控制台应用程序),OS X开发人员工具上试用。他们都在抱怨!
也是一样的原因!
/tmp/ccJ31810.o:功能'main'':
/tmp/ccJ31810.o(.text+0xf):未定义引用`cout''
/tmp/ccJ31810.o(.text+0x14):未定义引用
` ostream :: operator<<(char const *)''
collect2:ld返回1退出状态
但是......我认为#include应该在检查代码执行问题之前从
该文件中引入定义。
我不明白为什么它赢了'不管怎样,无论我看到什么教程,我读书的书都是b
,我读过的文章!有人能指出我正确的方向,一个完全无能为力的新手! (是的,我打电话给自己,所以你可以打电话给我
也是ONCE!)
提前感谢它,电子邮件被垃圾邮件拦截,删除单个期间
在@符号前面通过邮件回复。
--Tim
I must not be grasping anything here.
Just a simple application, as follows (as any first-program is...)
----
#include <iostream.h>
int main() {
cout <<"hello world";
return 0;
}
----
never compiles! Tried it on FreeBSD, OpenBSD, Windows (under Visual C++ for
Console App), OS X developer tools. THEY ALL complain!
pretty much the same reason too!
/tmp/ccJ31810.o: In function `main'':
/tmp/ccJ31810.o(.text+0xf): undefined reference to `cout''
/tmp/ccJ31810.o(.text+0x14): undefined reference to
`ostream::operator<<(char const *)''
collect2: ld returned 1 exit status
But... I thought the #include was supposed to bring in the definitions from
that file before checking the code for execution problems.
I don''t understand why it won''t work, no matter the tutorials I see, books I
read, articles I read! Can someone point me in the right direction, a
utterly clueless newbie! (yes, I called myself that, so you can call me
that ONCE, too!)
Appreciate it in advance, email is spam-blocked, remove the single period
PRIOR to the @ sign to reply by mail.
--Tim
推荐答案
改为:
#include< iostream>
使用命名空间std;
int main(){
cout<< 你好世界 << endl;
返回0;
}
iostream.h不推荐使用,标准C ++是用的
iostream没有.h
未定义的cout引用出现了因为
using namespace std不存在。
见 http://www.research.att.com/~bs/bs_faq2.html
Do this instead:
#include <iostream>
using namespace std;
int main() {
cout << "hello world" << endl;
return 0;
}
iostream.h is deprecated, the standard C++ is to use
iostream without .h
the undefined reference to cout appeared because
the "using namespace std" was not there.
see http://www.research.att.com/~bs/bs_faq2.html
好吧,你忘记了什么代码..
首先C ++标准鼓励你使用
#include< iostream>
和cout应该真的写成std ::在你的情况下cout
如果你不想在你的整个程序中写std :: cout
你应该把
在main()函数之前使用命名空间std;
这样你就可以在下面的行中写cout
和我在这里也有一个问题
我可以把使用命名空间bla吗?在我的代码中间?
或者我可以仅在某段代码中生效吗?
非常感谢
-
{Kelvin @ !!! }
Tim Judd < TJ ****** @ hotmail.com>在消息中写道
新闻:ir ******************** @ comcast.com ...
well, you forgot something in ur code..
first C++ standard encourages you to use
#include <iostream>
and cout should really be written as std::cout in your case
if you dont want to write std::cout through out your whole program
you should put
using namespace std;
before your main() function
so that you can just write cout in the following lines
and i also have a question here
can i put the "using namespace bla" in the middle of my code?
or can i make it effective in only a certain block of code??
thank you very much
--
{ Kelvin@!!! }
"Tim Judd" <tj******@hotmail.com> wrote in message
news:ir********************@comcast.com...
我一定不要在这里抓什么。
只是一个简单的应用程序,如下(任何第一个程序都是......)
----
#包括< iostream.h>
int main(){
cout<<" hello world" ;;
return 0;
} > ----
从不编译!在FreeBSD,OpenBSD,Windows(在控制台应用程序的Visual C ++
下),OS X开发人员工具上尝试过。他们都抱怨!
也是同样的原因!
/tmp/ccJ31810.o:在函数`main'':
/tmp/ccJ31810.o(.text + 0xf):未定义引用`cout''
/tmp/ccJ31810.o(.text+0x14):未定义引用
`ostream :: operator<<(char const *)''
collect2:ld返回1退出状态
但是......我认为#include应该在检查代码执行问题之前从该文件中引入定义
。
我不明白为什么它不起作用,无论我看到什么教程,我读过的书都是b b $ b,我读过的文章!有人能指出我正确的方向,一个完全无能为力的新手! (是的,我打电话给自己,所以你也可以打电话给我
那个ONCE!)
提前感谢它,电子邮件被垃圾邮件阻止,删除单个时期
在@符号之前通过邮件回复。
--Tim
I must not be grasping anything here.
Just a simple application, as follows (as any first-program is...)
----
#include <iostream.h>
int main() {
cout <<"hello world";
return 0;
}
----
never compiles! Tried it on FreeBSD, OpenBSD, Windows (under Visual C++ for Console App), OS X developer tools. THEY ALL complain!
pretty much the same reason too!
/tmp/ccJ31810.o: In function `main'':
/tmp/ccJ31810.o(.text+0xf): undefined reference to `cout''
/tmp/ccJ31810.o(.text+0x14): undefined reference to
`ostream::operator<<(char const *)''
collect2: ld returned 1 exit status
But... I thought the #include was supposed to bring in the definitions from that file before checking the code for execution problems.
I don''t understand why it won''t work, no matter the tutorials I see, books I read, articles I read! Can someone point me in the right direction, a
utterly clueless newbie! (yes, I called myself that, so you can call me
that ONCE, too!)
Appreciate it in advance, email is spam-blocked, remove the single period
PRIOR to the @ sign to reply by mail.
--Tim
改为:
#include< iostream>
使用命名空间std;
int main(){
cout<< 你好世界 << endl;
返回0;
}
iostream.h不推荐使用,标准C ++是用的
iostream没有.h
对cout的未定义引用出现了因为
你有iostream.h而不是iostream。
请参阅 http://www.research。 att.com/~bs/bs_faq2.html
Do this instead:
#include <iostream>
using namespace std;
int main() {
cout << "hello world" << endl;
return 0;
}
iostream.h is deprecated, the standard C++ is to use
iostream without .h
the undefined reference to cout appeared because
you had iostream.h instead of iostream.
see http://www.research.att.com/~bs/bs_faq2.html
这篇关于CX-Post:你好世界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!