stoopid begineer有问题 [英] stoopid begineer with a question

查看:39
本文介绍了stoopid begineer有问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用C ++构建Hello World程序。我在cygwin中使用c ++或

g ++编译器。我的错误代码看起来像这样,


#include< iostream>


int main()

{

cout<< Hello World;

返回;

}


它看起来像我的例子,但它不起作用。


g ++编译器告诉我以下内容:


hellotest.cpp:函数`int main()'':

hellotest.cpp:5:错误:`cout''未声明(首先使用此功能)

hellotest.cpp:5:错误:(每个未声明的标识符仅报告一次

表示它出现的每个函数。)

hellotest.cpp:6:错误:返回语句没有值,在函数中

返回'' int''


当我使用较旧的编译器Borland 4.5运行它时,它告诉我它不能读取输入文件helloworld.rc。


我做错了什么?

解决方案



knilges写道:

我正在尝试用C ++构建一个Hello World程序。我在cygwin中使用c ++或
g ++编译器。我的错误代码看起来像这样,
#include< iostream>

int main()
{
cout<< Hello World;
返回;
}


int main()

{

std :: cout<< Hello World << std :: endl;

返回0;

}
它看起来像我的例子,但它不起作用。

g ++的编译器告诉我以下内容:

hellotest.cpp:在函数`int main()''中:
hellotest.cpp:5:错误:`cout''未声明(第一次)使用此函数)
hellotest.cpp:5:错误:(每个未声明的标识符只报告一次它出现的每个函数。)
hellotest.cpp:6:错误:返回 - 没有价值的声明,在功能中
返回''int''

当我用较旧的编译器Borland 4.5运行时,它告诉我它不能读取输入文件helloworld.rc。


这是某种编译器相关文件。
我做错了什么?



knilges写道:

我正在尝试用C ++构建一个Hello World程序。我在cygwin中使用c ++或
g ++编译器。我的错误代码看起来像这样,
#include< iostream>

int main()
{
cout<< Hello World;


将以上行替换为:


std :: cout<< Hello World;


,你的程序编译正常。

return;


完全删除上述行,或将其替换为:


返回0;

}



祝你好运,

Tom


ro ********** @ gmail.com 写道:

knilges写道:

我正在尝试用C ++构建一个Hello World程序。我在cygwin中使用c ++或
g ++编译器。我的错误代码看起来像这样,
#include< iostream>

int main()
{
cout<< Hello World;
返回;
}





std :: cout<< Hello World << std :: endl;
返回0;
}




或者只是忽略返回 - 假定没有返回的main()

返回EXIT_SUCCESS。


-

Mike Smith


I am trying to build a Hello World program in C++. I am using the c++ or
g++ complier in cygwin. My mangled code looks like this,

#include <iostream>

int main ()
{
cout << "Hello World";
return;
}

It looks like my example but it isn''t working.

the compiler for g++ tells me the following:

hellotest.cpp: In function `int main()'':
hellotest.cpp:5: error: `cout'' undeclared (first use this function)
hellotest.cpp:5: error: (Each undeclared identifier is reported only once
for each function it appears in.)
hellotest.cpp:6: error: return-statement with no value, in function
returning ''int''

When I run it with an older complier Borland 4.5 it tells me that it can''t
read the input file helloworld.rc.

What am I doing wrong?

解决方案


knilges wrote:

I am trying to build a Hello World program in C++. I am using the c++ or
g++ complier in cygwin. My mangled code looks like this,

#include <iostream>

int main ()
{
cout << "Hello World";
return;
}
int main()
{
std::cout << "Hello World" << std::endl;
return 0;
}
It looks like my example but it isn''t working.

the compiler for g++ tells me the following:

hellotest.cpp: In function `int main()'':
hellotest.cpp:5: error: `cout'' undeclared (first use this function)
hellotest.cpp:5: error: (Each undeclared identifier is reported only once
for each function it appears in.)
hellotest.cpp:6: error: return-statement with no value, in function
returning ''int''

When I run it with an older complier Borland 4.5 it tells me that it can''t
read the input file helloworld.rc.
That is some sort of compiler dependent file.
What am I doing wrong?




knilges wrote:

I am trying to build a Hello World program in C++. I am using the c++ or
g++ complier in cygwin. My mangled code looks like this,

#include <iostream>

int main ()
{
cout << "Hello World";
replace the above line with:

std::cout << "Hello World";

and your program will compile fine.
return;
Delete the above line entirely, or replace it with:

return 0;
}



Best regards,

Tom


ro**********@gmail.com wrote:

knilges wrote:

I am trying to build a Hello World program in C++. I am using the c++ or
g++ complier in cygwin. My mangled code looks like this,

#include <iostream>

int main ()
{
cout << "Hello World";
return;
}



int main()
{
std::cout << "Hello World" << std::endl;
return 0;
}



Or just leave out the return - a main() with no return is assumed to
return EXIT_SUCCESS.

--
Mike Smith


这篇关于stoopid begineer有问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆