<tfoot id='OK1Cy'></tfoot>

  1. <small id='OK1Cy'></small><noframes id='OK1Cy'>

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

      指针和引用之间的低级区别是什么?

      What#39;s the low-level difference between a pointer an a reference?(指针和引用之间的低级区别是什么?)
    3. <tfoot id='YO6Nw'></tfoot>
    4. <i id='YO6Nw'><tr id='YO6Nw'><dt id='YO6Nw'><q id='YO6Nw'><span id='YO6Nw'><b id='YO6Nw'><form id='YO6Nw'><ins id='YO6Nw'></ins><ul id='YO6Nw'></ul><sub id='YO6Nw'></sub></form><legend id='YO6Nw'></legend><bdo id='YO6Nw'><pre id='YO6Nw'><center id='YO6Nw'></center></pre></bdo></b><th id='YO6Nw'></th></span></q></dt></tr></i><div id='YO6Nw'><tfoot id='YO6Nw'></tfoot><dl id='YO6Nw'><fieldset id='YO6Nw'></fieldset></dl></div>

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

              1. <small id='YO6Nw'></small><noframes id='YO6Nw'>

                  <tbody id='YO6Nw'></tbody>
                <legend id='YO6Nw'><style id='YO6Nw'><dir id='YO6Nw'><q id='YO6Nw'></q></dir></style></legend>
                本文介绍了指针和引用之间的低级区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                如果我们有这个代码:

                int foo=100;
                int& reference = foo;
                int* pointer = &reference;
                

                引用的数据和指针的数据没有实际的二进制差异.(它们都包含 foo 在内存中的位置)

                There's no actual binary difference in the reference's data and the pointer's data. (they both contain the location in memory of foo)

                第 2 部分

                那么指针和引用之间的所有其他差异在哪里(在这里讨论)进来?编译器是否强制执行它们,或者它们实际上是汇编级别上的不同类型的变量?换句话说,以下是否产生相同的汇编语言?

                So where do all the other differences between pointers and references (discussed here) come in? Does the compiler enforce them or are they actually different types of variables on the assemebly level? In other words, do the following produce the same assembly language?

                foo=100;
                int& reference=foo;
                reference=5;
                
                foo=100;
                int* pointer=&foo;
                *pointer=5;
                

                推荐答案

                理论上,它们可以以不同的方式实现.

                Theoretically, they could be implemented in different ways.

                实际上,我见过的每个编译器都编译指向相同机器代码的指针和引用.区别完全在于语言层面.

                In practice, every compiler I've seen compiles pointers and references to the same machine code. The distinction is entirely at the language level.

                但是,就像 cdiggins 所说的那样,您不应该依赖这种概括,直到您验证它对您的编译器和平台来说是正确的.

                But, like cdiggins says, you shouldn't depend on that generalization until you've verified it's true for your compiler and platform.

                这篇关于指针和引用之间的低级区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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++ 引用发生变化)
                <i id='CnTNJ'><tr id='CnTNJ'><dt id='CnTNJ'><q id='CnTNJ'><span id='CnTNJ'><b id='CnTNJ'><form id='CnTNJ'><ins id='CnTNJ'></ins><ul id='CnTNJ'></ul><sub id='CnTNJ'></sub></form><legend id='CnTNJ'></legend><bdo id='CnTNJ'><pre id='CnTNJ'><center id='CnTNJ'></center></pre></bdo></b><th id='CnTNJ'></th></span></q></dt></tr></i><div id='CnTNJ'><tfoot id='CnTNJ'></tfoot><dl id='CnTNJ'><fieldset id='CnTNJ'></fieldset></dl></div>
                  <legend id='CnTNJ'><style id='CnTNJ'><dir id='CnTNJ'><q id='CnTNJ'></q></dir></style></legend>

                      • <tfoot id='CnTNJ'></tfoot>

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

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