endl错误(极端新手) [英] endl error (extreme novice)

查看:99
本文介绍了endl错误(极端新手)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理我的第二个程序,所以请耐心等待。

当我尝试编译它时,我收到两条错误消息(3种类型):

函数`int main()'':

第6行:`endl''未声明(首先使用此函数)

第8行`end' '未声明(首先使用此功能)


我正在使用一个名为Dev-C ++的编译器,所以如果有人知道更好的编译器,我就是b $ b am接受推荐。

谢谢,


这是我目前的计划:


#include< iostream> ;

int main()

{

int x = 5;

int y = 7;

std :: cout<< endl;

std :: cout<< x + y<< " " << x * y;

std :: cout<<结束;

返回0;

}

解决方案

#include< ;&的iostream GT;


int main()

{

int x = 5;

int y = 7;

std :: cout<< endl;

std :: cout<< x + y<< " " << x * y;

std :: cout<<结束;

返回0;

}



endl是(就像cout一样)在std的范围内。

所以你必须把std ::放在它之前。

你可以选择在#include< iostream>

之后使用这一行namespace std;


它将声明std作为标准命名空间



Jd ****** @ gmail。 com 写道:


我正在处理我的第二个程序,所以请耐心等待。

当我尝试编译时它,我收到两条错误消息(有点3):


函数`int main()'':

第6行:`endl''未声明(首先使用此功能)

第8行结束未声明(首次使用此功能)


我正在使用名为Dev-的编译器C ++,所以如果有人知道一个更好的,我可以接受建议。



Dev-C ++是环境。我记得,它使用的编译器是g ++

并且它没有任何问题。


谢谢你,


>这是我当前的程序:



#include< iostream>



你知道上面那行吗?


int main()

{

int x = 5;

int y = 7;

std :: cout<< ENDL;



你知道为什么你在cout前写了std ::。使用endl执行相同的

,即将endl更改为std :: endl,你的问题将会消失,但你知道为什么吗?


std :: cout<< x + y<< " " << x * y;



作为附带问题,您确定该行是否正确?当你得到

程序时,输出是你想要的吗?


std :: cout<<结束;



endl已经结束。我希望你不是那个意思。


返回0;

}



你从哪里学习C ++并不能解释这个?一本书?或者是一个

的网站?因为代码中的错误,正确地将std :: in

前面的一个名称(cout)但错误地从另一个名称中删除了

(endl),这是一个奇怪的一本书或一本不错的网络教程(其中很少有b
)。


你有没有任何其他语言的编程经验C ++?如果

如此,则 http://www.acceleratedcpp.com/ 是一本很棒的书,教你

C ++编程。但它确实假设了一些以前的,非C ++,

的体验。


Gavin Deane


Jd******@gmail.com 写道:
< blockquote class =post_quotes>
我正在处理我的第二个程序,所以请耐心等待。

当我尝试编译它时,我收到两条错误消息(3种) :


函数`int main()'':

第6行:`endl''未声明(首先使用此函数)

第8行结束未声明(首次使用此功能)


我正在使用名为Dev-C ++的编译器,所以如果有人知道更好的编译器,我

对建议持开放态度。



Dev-C ++是环境。我记得,它使用的编译器是g ++

并且它没有任何问题。


谢谢你,


>这是我当前的程序:



#include< iostream>



你知道上面那行吗?


int main()

{

int x = 5;

int y = 7;

std :: cout<< ENDL;



你知道为什么你在cout前写了std ::。使用endl执行相同的

,即将endl更改为std :: endl,你的问题将会消失,但你知道为什么吗?


std :: cout<< x + y<< " " << x * y;



作为附带问题,您确定该行是否正确?当你得到

程序时,输出是你想要的吗?


std :: cout<<结束;



endl已经结束。我希望你不是那个意思。


返回0;

}



你从哪里学习C ++并不能解释这个?一本书?或者是一个

的网站?因为代码中的错误,正确地将std :: in

前面的一个名称(cout)但错误地从另一个名称中删除了

(endl),这是一个奇怪的一本书或一本不错的网络教程(其中很少有b
)。


你有没有任何其他语言的编程经验C ++?如果

如此,则 http://www.acceleratedcpp.com/ 是一本很棒的书,教你

C ++编程。但它确实假设了一些以前的,非C ++,

的体验。


Gavin Deane

I am working on my second program ever, so bear with me.
When I try to compile it, I get two error messages(sort of 3):

In function `int main()'':
line 6: `endl'' undeclared (first use this function)
line 8 `end'' undeclared (first use this function)

I''m using a compiler called Dev-C++, so if anyone knows a better one, I
am open to recommendations.
Thank you,

Here is my current program:

#include <iostream>
int main()
{
int x = 5;
int y = 7;
std::cout << endl;
std::cout << x + y << " " << x * y;
std::cout << end;
return 0;
}

解决方案

#include <iostream>

int main()
{
int x = 5;
int y = 7;
std::cout << endl;
std::cout << x + y << " " << x * y;
std::cout << end;
return 0;
}

endl is(just as cout) within the scope of std.
so you have to put std:: before it.
you can alternatively put this line after #include <iostream>
using namespace std;

it will declare "std" as the "standard" namespace



Jd******@gmail.com wrote:

I am working on my second program ever, so bear with me.
When I try to compile it, I get two error messages(sort of 3):

In function `int main()'':
line 6: `endl'' undeclared (first use this function)
line 8 `end'' undeclared (first use this function)

I''m using a compiler called Dev-C++, so if anyone knows a better one, I
am open to recommendations.

Dev-C++ is the environment. As I recall, the compiler it uses is g++
and there''s nothing wrong with it.

Thank you,

>Here is my current program:


#include <iostream>

Do you know what that line above does?

int main()
{
int x = 5;
int y = 7;
std::cout << endl;

Do you know why you have written std:: in front of cout. Do the same
with endl, i.e. change endl to std::endl, and your problem will go
away, but do you know why?

std::cout << x + y << " " << x * y;

As a side issue, are you sure that line is correct? When you get the
program working, is the output what you intended?

std::cout << end;

endl has become end. I expect you didn''t mean that.

return 0;
}

Where are you learning C++ from that doesn''t explain this? A book? Or a
website? Because the error in your code, correctly putting std:: in
front of one name (cout) but incorrectly leaving it off another name
(endl), is a strange one for a book or a decent web tutorial (of which
there are very few) to make.

Have you got any programming experience in languages other than C++? If
so, then http://www.acceleratedcpp.com/ is a superb book to teach you
C++ programming. But it does presume some previous, non-C++,
experience.

Gavin Deane



Jd******@gmail.com wrote:

I am working on my second program ever, so bear with me.
When I try to compile it, I get two error messages(sort of 3):

In function `int main()'':
line 6: `endl'' undeclared (first use this function)
line 8 `end'' undeclared (first use this function)

I''m using a compiler called Dev-C++, so if anyone knows a better one, I
am open to recommendations.

Dev-C++ is the environment. As I recall, the compiler it uses is g++
and there''s nothing wrong with it.

Thank you,

>Here is my current program:


#include <iostream>

Do you know what that line above does?

int main()
{
int x = 5;
int y = 7;
std::cout << endl;

Do you know why you have written std:: in front of cout. Do the same
with endl, i.e. change endl to std::endl, and your problem will go
away, but do you know why?

std::cout << x + y << " " << x * y;

As a side issue, are you sure that line is correct? When you get the
program working, is the output what you intended?

std::cout << end;

endl has become end. I expect you didn''t mean that.

return 0;
}

Where are you learning C++ from that doesn''t explain this? A book? Or a
website? Because the error in your code, correctly putting std:: in
front of one name (cout) but incorrectly leaving it off another name
(endl), is a strange one for a book or a decent web tutorial (of which
there are very few) to make.

Have you got any programming experience in languages other than C++? If
so, then http://www.acceleratedcpp.com/ is a superb book to teach you
C++ programming. But it does presume some previous, non-C++,
experience.

Gavin Deane


这篇关于endl错误(极端新手)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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