<small id='XOj6k'></small><noframes id='XOj6k'>

    <legend id='XOj6k'><style id='XOj6k'><dir id='XOj6k'><q id='XOj6k'></q></dir></style></legend>
    • <bdo id='XOj6k'></bdo><ul id='XOj6k'></ul>

        <tfoot id='XOj6k'></tfoot>
      1. <i id='XOj6k'><tr id='XOj6k'><dt id='XOj6k'><q id='XOj6k'><span id='XOj6k'><b id='XOj6k'><form id='XOj6k'><ins id='XOj6k'></ins><ul id='XOj6k'></ul><sub id='XOj6k'></sub></form><legend id='XOj6k'></legend><bdo id='XOj6k'><pre id='XOj6k'><center id='XOj6k'></center></pre></bdo></b><th id='XOj6k'></th></span></q></dt></tr></i><div id='XOj6k'><tfoot id='XOj6k'></tfoot><dl id='XOj6k'><fieldset id='XOj6k'></fieldset></dl></div>
      2. C++ 引用中 & 符号在语义上的准确位置是什么

        What#39;s the semantically accurate position for the ampersand in C++ references(C++ 引用中 符号在语义上的准确位置是什么)
        <tfoot id='KnwOn'></tfoot>
        1. <i id='KnwOn'><tr id='KnwOn'><dt id='KnwOn'><q id='KnwOn'><span id='KnwOn'><b id='KnwOn'><form id='KnwOn'><ins id='KnwOn'></ins><ul id='KnwOn'></ul><sub id='KnwOn'></sub></form><legend id='KnwOn'></legend><bdo id='KnwOn'><pre id='KnwOn'><center id='KnwOn'></center></pre></bdo></b><th id='KnwOn'></th></span></q></dt></tr></i><div id='KnwOn'><tfoot id='KnwOn'></tfoot><dl id='KnwOn'><fieldset id='KnwOn'></fieldset></dl></div>
          <legend id='KnwOn'><style id='KnwOn'><dir id='KnwOn'><q id='KnwOn'></q></dir></style></legend>

            • <bdo id='KnwOn'></bdo><ul id='KnwOn'></ul>

              <small id='KnwOn'></small><noframes id='KnwOn'>

                    <tbody id='KnwOn'></tbody>
                  本文介绍了C++ 引用中 & 符号在语义上的准确位置是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  众所周知,声明指针的语义准确方法是

                  It's pretty common knowledge that the semantically accurate way to declare pointers is

                  int *x;
                  

                  代替

                  int* x;
                  

                  这是因为 C 将 *x 视为 int,而不是将 x 视为 int 指针.

                  This is because C sees *x as an int, not x as an int pointer.

                  这很容易证明

                  int* a, b;
                  

                  其中a 是一个int 指针,而b 是一个int.

                  where a is an int pointer, while b is an int.

                  在 Stack Overflow 上至少有 5 个重复的问题讨论了这个问题的指针.但是引用呢?

                  There are at least 5 duplicate questions on Stack Overflow that discuss this issue for pointers. But what about references?

                  推荐答案

                  在研究这个问题时,我已经找到了答案:

                  While researching for this question, I already found the answer:

                  & 需要像 * 一样编写.

                  The & needs to be written just like the *.

                  演示代码类似于指针演示代码:

                  The demonstration code is similar to the pointer demonstration code:

                  int main() {
                      int a = 0;
                      int b = 1;
                  
                      int& ar = a, br = b;
                  
                      br = 2;
                  
                      return b;
                  }
                  

                  这返回 1,这意味着 ar 是一个 int 引用,而 br 只是一个整数.

                  This returns 1, which means that ar is an int reference, while br is just an integer.

                  这篇关于C++ 引用中 & 符号在语义上的准确位置是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  C++ stl unordered_map implementation, reference validity(C++ stl unordered_map 实现,参考有效性)
                  C++: Is it possible to use a reference as the value in a map?(C++:是否可以使用引用作为映射中的值?)
                  Where ampersand quot;amp;quot; can be put when passing argument by reference?(其中符号“amp;通过引用传递参数时可以放置吗?)
                  Why can a non-const reference parameter be bound to a temporary object?(为什么可以将非常量引用参数绑定到临时对象?)
                  What is a dangling reference?(什么是悬空引用?)
                  C++ reference changes when push_back new element to std::vector(当 push_back 新元素到 std::vector 时,C++ 引用发生变化)

                    <small id='C1RBv'></small><noframes id='C1RBv'>

                    • <tfoot id='C1RBv'></tfoot>
                      <i id='C1RBv'><tr id='C1RBv'><dt id='C1RBv'><q id='C1RBv'><span id='C1RBv'><b id='C1RBv'><form id='C1RBv'><ins id='C1RBv'></ins><ul id='C1RBv'></ul><sub id='C1RBv'></sub></form><legend id='C1RBv'></legend><bdo id='C1RBv'><pre id='C1RBv'><center id='C1RBv'></center></pre></bdo></b><th id='C1RBv'></th></span></q></dt></tr></i><div id='C1RBv'><tfoot id='C1RBv'></tfoot><dl id='C1RBv'><fieldset id='C1RBv'></fieldset></dl></div>
                          <bdo id='C1RBv'></bdo><ul id='C1RBv'></ul>
                          <legend id='C1RBv'><style id='C1RBv'><dir id='C1RBv'><q id='C1RBv'></q></dir></style></legend>
                              <tbody id='C1RBv'></tbody>