<tfoot id='4hOYS'></tfoot>

      <i id='4hOYS'><tr id='4hOYS'><dt id='4hOYS'><q id='4hOYS'><span id='4hOYS'><b id='4hOYS'><form id='4hOYS'><ins id='4hOYS'></ins><ul id='4hOYS'></ul><sub id='4hOYS'></sub></form><legend id='4hOYS'></legend><bdo id='4hOYS'><pre id='4hOYS'><center id='4hOYS'></center></pre></bdo></b><th id='4hOYS'></th></span></q></dt></tr></i><div id='4hOYS'><tfoot id='4hOYS'></tfoot><dl id='4hOYS'><fieldset id='4hOYS'></fieldset></dl></div>
    1. <legend id='4hOYS'><style id='4hOYS'><dir id='4hOYS'><q id='4hOYS'></q></dir></style></legend>

      <small id='4hOYS'></small><noframes id='4hOYS'>

      • <bdo id='4hOYS'></bdo><ul id='4hOYS'></ul>

    2. 为什么按位移位(&lt;&lt; 和 &gt;&gt;)用于 cout 和 cin?

      时间:2023-10-17
        <i id='H7NGc'><tr id='H7NGc'><dt id='H7NGc'><q id='H7NGc'><span id='H7NGc'><b id='H7NGc'><form id='H7NGc'><ins id='H7NGc'></ins><ul id='H7NGc'></ul><sub id='H7NGc'></sub></form><legend id='H7NGc'></legend><bdo id='H7NGc'><pre id='H7NGc'><center id='H7NGc'></center></pre></bdo></b><th id='H7NGc'></th></span></q></dt></tr></i><div id='H7NGc'><tfoot id='H7NGc'></tfoot><dl id='H7NGc'><fieldset id='H7NGc'></fieldset></dl></div>
        <tfoot id='H7NGc'></tfoot>

                <bdo id='H7NGc'></bdo><ul id='H7NGc'></ul>
                  <tbody id='H7NGc'></tbody>

                <legend id='H7NGc'><style id='H7NGc'><dir id='H7NGc'><q id='H7NGc'></q></dir></style></legend>
              • <small id='H7NGc'></small><noframes id='H7NGc'>

                本文介绍了为什么按位移位(&lt;&lt; 和 &gt;&gt;)用于 cout 和 cin?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                问题确实在标题中;我敢肯定有一些合乎逻辑的,但现在我很难过!

                Question is in the title really; I'm sure there is something logical, but for now I'm stumped!

                推荐答案

                根据C++的设计与演化的§8.3.1:

                Doug McIlroy 通过类比 UNIX shell 中的 I/O 重定向操作符(>、>>、| 等)提出了提供输出操作符而不是命名输出函数的想法

                The idea of providing an output operator rather than a named output function was suggested by Doug McIlroy by analogy with the I/O redirection operators in the UNIX shell (>, >>, |, etc.)

                [...]

                输入和输出操作考虑了几个操作符:赋值运算符是输入和输出的候选者,但它以错误的方式绑定.即 cout=a=b 将被解释为 cout=(a=b),并且大多数人似乎更喜欢输入运算符与输出运算符不同.运算符<>都试过了,但是小于"和大于"的含义已经牢牢地植入人们的脑海中,以至于新的I/O语句从所有实际目的来看都是不可读的(<<<>>> 似乎不是这种情况).除此之外,'<'就在大多数键盘上的,"上方,人们写这样的表达方式:

                Several operators were considered for input and output operations: the assignment operator was a candidate for both input and output, but it binds the wrong way. That is cout=a=b would be interpreted as cout=(a=b), and most people seemed to prefer the input operator to be different from the output operator. The operators < and > were tried, but the meanings "less than" and "greater than" were so firmly implanted in people's minds that the new I/O statements were for all practical purposes unreadable (this does not appear to be the case for << and >>). Apart from that, '<' is just above ',' on most keyboards, and people were writing expressions like this:

                cout < x , y, z;
                

                为此提供好的错误消息并不容易.

                It is not easy to give good error messages for this.

                这篇关于为什么按位移位(&lt;&lt; 和 &gt;&gt;)用于 cout 和 cin?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何读写 STL C++ 字符串? 下一篇:C++:ofstream 类将文件保存到哪里?

                相关文章

                    <bdo id='Bxjae'></bdo><ul id='Bxjae'></ul>

                1. <legend id='Bxjae'><style id='Bxjae'><dir id='Bxjae'><q id='Bxjae'></q></dir></style></legend>
                    <tfoot id='Bxjae'></tfoot>
                    <i id='Bxjae'><tr id='Bxjae'><dt id='Bxjae'><q id='Bxjae'><span id='Bxjae'><b id='Bxjae'><form id='Bxjae'><ins id='Bxjae'></ins><ul id='Bxjae'></ul><sub id='Bxjae'></sub></form><legend id='Bxjae'></legend><bdo id='Bxjae'><pre id='Bxjae'><center id='Bxjae'></center></pre></bdo></b><th id='Bxjae'></th></span></q></dt></tr></i><div id='Bxjae'><tfoot id='Bxjae'></tfoot><dl id='Bxjae'><fieldset id='Bxjae'></fieldset></dl></div>
                  1. <small id='Bxjae'></small><noframes id='Bxjae'>