不明白这个C ++练习 [英] Don't understand this C++ exercise

查看:86
本文介绍了不明白这个C ++练习的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我已经在C编码好几年了,我开始使用

C ++。我接受了以下练习,但我并不完全理解它。我想知道你们有没有人可以提供帮助。


#include< iostream>


使用命名空间std;


int main(){

cout<< hello world;

返回0;

}


为什么cout向左移动hello world时间?

Hi guys,

I''ve been coding in C for several years and I''m getting started with
C++. I was given the following exercise to do and I don''t quite
understand it. I was wondering if any of you guys could help.

#include <iostream>

using namespace std;

int main() {
cout << "hello world";
return 0;
}

Why is cout being shifted left "hello world" times?

推荐答案

Suzie wintroll写道:
Suzie wintroll wrote:
大家好,


你好wintroll。

cout<< 你好世界;
为什么cout向左移动hello world时间?
Hi guys,
Hi wintroll.
cout << "hello world"; Why is cout being shifted left "hello world" times?




我们建议你阅读Herbert Schildt的作品,以帮助克服你的
金发。


-

Phlip
http://industrialxp.org/community/bi...UserInterfaces





Suzie写道:


Suzie wrote:
大家好,

我已经用C编写了好几年了,我开始使用
C ++。我接受了以下练习,我不太了解它。我想知道你们中是否有人可以提供帮助。

#include< iostream>

使用命名空间std;

int main(){
cout<< hello world;
返回0;
}

为什么cout向左移动hello world时间?
Hi guys,

I''ve been coding in C for several years and I''m getting started with
C++. I was given the following exercise to do and I don''t quite
understand it. I was wondering if any of you guys could help.

#include <iostream>

using namespace std;

int main() {
cout << "hello world";
return 0;
}

Why is cout being shifted left "hello world" times?




C ++有一个叫做运算符重载的东西,它允许你根据定义的类重新定义各种运算符。 <<和>>由于I / O目的导致输出或输入到流,通常会因为b $ b而被重载。在

特别是STL为流类和基本数据

类型定义了这些。由于cout在STL中被定义为输出流,特别是控制台输出,所以该行使用STL

重载来放置字符串hello world。到了控制台。


David



C++ has something called ''operator overloading'' which lets you redefine
various operators in terms of defined classes. << and >> are commonly
overloaded for I/O purposes to cause output or input to a stream. In
particular the STL defines these for stream classes and basic data
types. Since cout is defined in the STL as an output stream,
specifically the console output, the line in question uses the STL
overloading to put the string "hello world" out to the console.

David


Suzie写道:
Suzie wrote:
嗨伙计们,

我已经在C编码了好几年了,我开始使用
C ++。我接受了以下练习,我不太了解它。我想知道你们中是否有人可以提供帮助。

#include< iostream>

使用命名空间std;

int main(){
cout<< hello world;
返回0;
}

为什么cout向左移动hello world时间?
Hi guys,

I''ve been coding in C for several years and I''m getting started with
C++. I was given the following exercise to do and I don''t quite
understand it. I was wondering if any of you guys could help.

#include <iostream>

using namespace std;

int main() {
cout << "hello world";
return 0;
}

Why is cout being shifted left "hello world" times?




<<是一个按位运算符和一个输出流运算符。


因为你有以前的编程经验我建议你阅读

加速C + + QUOT;作者:Andrew Koenig,Barbara Moo。

对于本书和其他书籍的书评,请查看 http://www.accu.org

书评部分。


另外看看:

http://www23.brinkster.com/noicys/learningcpp .htm


-

Ioannis Vranos

http://www23.brinkster.com/noicys



<< is both a bitwise operator and an output stream operator.


Since you have former programming experience I suggest you read
"Accelerated C++" by Andrew Koenig, Barbara Moo.
For book reviews for this and other books, check http://www.accu.org at
the book reviews section.

Also have a look to this:

http://www23.brinkster.com/noicys/learningcpp.htm

--
Ioannis Vranos

http://www23.brinkster.com/noicys


这篇关于不明白这个C ++练习的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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