正确的C ++教程第3部分“循环简介”可用(Windows,mingw / msvc / std) [英] Correct C++ tutorial part 3 "Intro to loops" available (Windows, mingw/msvc/std)

查看:48
本文介绍了正确的C ++教程第3部分“循环简介”可用(Windows,mingw / msvc / std)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试过的Correct C ++教程的第三部分现已推出,

虽然现在只有Word格式(如果没有Word,请使用免费的Open Office),

和此外,它还没有得到广泛的评论 - 欢迎评论!


循环简介

< url:http:// home.no.net/dubjai/win32cpptut/w32cpptut_01_03.doc>


和以前一样,我希望这里有精神食粮和技术要点

我们对于新手和有经验的人来说,可以强烈不同意。


和以前一样,邀请评论是_fix_任何

不正确或者演示文稿,管他呢;你的意见是有价值的。


前两部分,Hello,world!和变量,可以作为Word文档和(现在结构合理!;-))HTML $

< url:http: //home.no.net/dubjai/win32cpptut/html/>


再次,第2部分,感谢Stephan Br?nniman帮助

从Word转换为HTML,以及有用的评论&校正。

[我无意中将此消息发布到comp.std.c ++:darn那个鼠标!

如果任何主持人阅读此内容并取消该消息,请。


-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么会这样这么糟糕吗?

A:热门帖子。

问:usenet和电子邮件中最烦人的是什么?

The third part of my attempted Correct C++ tutorial is now available,
although for now only in Word format (use free Open Office if no Word),
and also, it''s not yet been extensively reviewed -- comments welcome!

"Intro to loops"
<url: http://home.no.net/dubjai/win32cpptut/w32cpptut_01_03.doc>

As before I expect that here''s mental food and technical points that
we can strongly disagree about, for both newbie and the experienced.

And as before the point of inviting comments is to _fix_ anything
incorrect, or the presentation, or whatever; your input is valuable.

The first two parts, "Hello, world!" and "Variables", are available
both as Word docs and (now reasonably structured! ;-)) HTML at

<url: http://home.no.net/dubjai/win32cpptut/html/>

Again, re part 2, thanks to Stephan Br?nniman for helping with the
conversion from Word to HTML, and helpful comments & corrections.
[I inadvertently posted this message to comp.std.c++: darn that mouse!
If any of the moderators read this and can cancel that, please.]

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

推荐答案

你好Alf,


在第8章中可能:始终使用整数类型如int为

循环控制变量"是'强者'。我认为是这样的:

"在处理花车时选择了所需的精度,避免''相等''

运营商'。


另一个陷阱可能是:for(unsigned int i = 5; i> = 0; --i){...

}


祝你好运,

Bogdan Sintoma

Hi Alf,

In the chapter 8 maybe: "Always use an integral type such as int for a
loop control variable" is ''to strong''. I think to something like:
"chose the desired precision when dealing with floats and avoid ''equal''
operators".

Another pitfall could be: for( unsigned int i = 5; i >= 0; --i ) { ...
}

Best regards,
Bogdan Sintoma


* Alf P. Steinbach:
* Alf P. Steinbach:
第三我现在可以使用正确的C ++教程的一部分,
虽然目前只有Word格式(如果没有Word,请使用免费的Open Office),
以及它尚未得到广泛审查 - 欢迎评论!

循环简介
< url:http://home.no.net/dubjai/win32cpptut/w32cpptut_01_03.doc>
和以前一样,我希望这里的心理食品和技术要点对于新手和经验丰富的人来说都是非常不同意的。

和以前一样,邀请评论的重点是到_fix_任何<不正确,或演示文稿,或其他;你的意见是有价值的。
The third part of my attempted Correct C++ tutorial is now available,
although for now only in Word format (use free Open Office if no Word),
and also, it''s not yet been extensively reviewed -- comments welcome!

"Intro to loops"
<url: http://home.no.net/dubjai/win32cpptut/w32cpptut_01_03.doc>

As before I expect that here''s mental food and technical points that
we can strongly disagree about, for both newbie and the experienced.

And as before the point of inviting comments is to _fix_ anything
incorrect, or the presentation, or whatever; your input is valuable.




好​​吧,我自己发现了一个大错误! :-o


在第4部分,[陷阱:]使用赋值而不是比较,

我将if条件描述为接受非bool值因为它将
转换为bool为数字零/非零。这是一个有效的信念,可能是它在C中的方式,但它并不是如何实际在C ++中工作的b $ b。在C ++中,相同的_effect_是通过将非bool值(零,非零)隐式转换为bool来实现的。


现在更正了.. 。


-

答:因为它弄乱了人们通常阅读文字的顺序。

问:为什么是这是一件坏事吗?

答:热门发布。

问:usenet和电子邮件中最烦人的是什么?



Well, I discovered one Big Blunder myself! :-o

In section 4, "[Pitfall:] Using assignment instead of comparision",
I described an if-condition as accepting non-bool values because it
converted bool to numerical zero / non-zero. That was correct as an
effective belief, and may be the way it is in C, but it''s not how it
actually works in C++. In C++ the same _effect_ is achieved by having
implicit conversion of non-bool values (zero, non-zero) to bool.

Now corrected...

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


* Bogdan Sintoma:
* Bogdan Sintoma:
嗨Alf,

在第8章中可能:始终使用整数类型如int
循环控制变量是'强者'。我认为这样的事情:
在处理浮动时选择了所需的精度,并避免等于运算符。


好​​吧,这是我的理由:


*如果您使用例如''double''作为循环控制变量(计数器),你

使用整数更新(例如增量)或非整数更新。


*如果你使用整数更新,你应该使用整数类型作为

变量。


*如果你使用非整数更新你有麻烦,并且/或者是以不必要的复杂方式做事;无论哪种方式,

解决方案是使用整数类型作为循环控制变量。


此外,需要很多文本来解释如何比较

浮点值安全,以及实现的安全程度是多少(这是一个高级主题,人们可以写一本关于......的全书)。 br />

这有意义吗?

另一个陷阱可能是:for(unsigned int i = 5; i> = 0; --i){.. 。
}
Hi Alf,

In the chapter 8 maybe: "Always use an integral type such as int for a
loop control variable" is ''to strong''. I think to something like:
"chose the desired precision when dealing with floats and avoid ''equal''
operators".
Well, here''s my reasoning:

* If you use e.g. ''double'' as a loop control variable (counter), you
either use integer update (e.g. increment) or non-integer update.

* If you use integer update you should use integer type for the
variable.

* If you use non-integer update you''re in trouble, and/or are
doing things in a needlessly complicated way; either way the
solution is to use integer type for the loop control variable.

Additionally, it would take much text to explain how to compare
floating point values "safely", and what degree of safety can be
achieved (it''s an advanced topic one can write a whole book about...).

Does this make sense?
Another pitfall could be: for( unsigned int i = 5; i >= 0; --i ) { ...
}




是的,谢谢。


我在这里的想法是只引入最低限度的

_general_功能,不仅仅是优化的东西,或者只有在特殊情况下才有用的
,所以还没有''unsigned'',只有''int''。


但也许这个陷阱是如此常见以至于即使在这个早期阶段也应该被提及




-

答:因为它弄乱了人们规范的顺序lly阅读文字。

问:为什么这么糟糕?

A:热门帖子。

问:什么是最多的在usenet和电子邮件中烦人的事情?



Yes, thanks.

My thinking here has been to introduce only the bare minimum of
_general_ functionality, not things that are really only optimization or
only useful in special cases, and so no ''unsigned'' yet, only ''int''.

But perhaps that pitfall is so common that it deserves to be mentioned
even at this early stage?

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


这篇关于正确的C ++教程第3部分“循环简介”可用(Windows,mingw / msvc / std)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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