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

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

        <legend id='4mIEm'><style id='4mIEm'><dir id='4mIEm'><q id='4mIEm'></q></dir></style></legend>
        <tfoot id='4mIEm'></tfoot>

      1. *&amp; 有什么用?函数参数中的平均值

        时间:2023-09-27

        <tfoot id='glQUU'></tfoot>
            • <small id='glQUU'></small><noframes id='glQUU'>

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

                  本文介绍了*&amp; 有什么用?函数参数中的平均值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如果我有一个接受 int *& 的函数,这意味着什么?如何仅将 int 或 int 指针传递给该函数?

                  If I have a function that takes int *&, what does it means? How can I pass just an int or a pointer int to that function?

                  function(int *& mynumber);
                  

                  每当我尝试传递指向该函数的指针时,它都会说:

                  Whenever I try to pass a pointer to that function it says:

                  error: no matching function for call to 'function(int *)'
                  note: candidate is 'function(int *&)'
                  

                  推荐答案

                  它是对 int 指针的引用.这意味着有问题的函数可以修改指针以及 int 本身.

                  It's a reference to a pointer to an int. This means the function in question can modify the pointer as well as the int itself.

                  你可以只传递一个指针,一个复杂的问题是指针需要是一个左值,而不仅仅是一个右值,例如

                  You can just pass a pointer in, the one complication being that the pointer needs to be an l-value, not just an r-value, so for example

                  int myint;
                  function(&myint);
                  

                  单独是不够的,也不允许 0/NULL,如:

                  alone isn't sufficient and neither would 0/NULL be allowable, Where as:

                  int myint;
                  int *myintptr = &myint;
                  function(myintptr);
                  

                  可以接受.当函数返回时,myintptr 很可能不再指向它最初指向的内容.

                  would be acceptable. When the function returns it's quite possible that myintptr would no longer point to what it was initially pointing to.

                  int *myintptr = NULL;
                  function(myintptr);
                  

                  如果函数希望在给定 NULL 指针时分配内存,也可能有意义.检查随函数提供的文档(或阅读源代码!)以了解如何使用指针.

                  might also make sense if the function was expecting to allocate the memory when given a NULL pointer. Check the documentation provided with the function (or read the source!) to see how the pointer is expected to be used.

                  这篇关于*&amp; 有什么用?函数参数中的平均值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:我可以对字段和构造函数参数使用相同的名称吗? 下一篇:正确使用 Eigen::Ref&gt;班级

                  相关文章

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

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

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