久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

*& 的含義和**&在 C++ 中

Meaning of *amp; and **amp; in C++(*amp; 的含義和**amp;在 C++ 中)
本文介紹了*& 的含義和**&在 C++ 中的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我在函數(shù)聲明中多次發(fā)現(xiàn)這些符號,但我不知道它們是什么意思.

I found these symbols in a function declaration several times, but I don't know what they mean.

示例:

void raccogli_dati(double **& V, double **p, int N) { 
  int ultimo = 3; 
  V = new double * [N/2]; 
  for(int i=0; i < N/2; i++) { 
    V[i] = new double[N/2], std :: clog << "digita " << N/2 - i
                 << " valori per la parte superiore della matrice V: "; 
    for(int j=i; j < N/2; j++) 
      std :: cin >> V[i][j], p[ultimo++][0] = (V[i][j] /= sqrt(p[i][0]*p[j][0]));
  } 
  for(int i=1; i < N/2; i++) 
    for(int j=0; j < i; j++) 
       V[i][j] = V[j][i];
}

推薦答案

即以引用方式取參數(shù).因此,在第一種情況下,您通過引用獲取指針參數(shù),因此您對指針值所做的任何修改都會反映在函數(shù)之外.第二個與第一個相似,唯一的區(qū)別是它是一個雙指針.看這個例子:

That is taking the parameter by reference. So in the first case you are taking a pointer parameter by reference so whatever modification you do to the value of the pointer is reflected outside the function. Second is the simlilar to first one with the only difference being that it is a double pointer. See this example:

void pass_by_value(int* p)
{
    //Allocate memory for int and store the address in p
    p = new int;
}

void pass_by_reference(int*& p)
{
    p = new int;
}

int main()
{
    int* p1 = NULL;
    int* p2 = NULL;

    pass_by_value(p1); //p1 will still be NULL after this call
    pass_by_reference(p2); //p2 's value is changed to point to the newly allocate memory

    return 0;
}

這篇關于*&amp; 的含義和**&amp;在 C++ 中的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

Difference between std::reference_wrapper and simple pointer?(std::reference_wrapper 和簡單指針的區(qū)別?)
Difference between const. pointer and reference?(常量之間的區(qū)別.指針和引用?)
How to access the contents of a vector from a pointer to the vector in C++?(c++ - 如何從指向向量的指針訪問向量的內(nèi)容?)
Why can#39;t I do polymorphism with normal variables?(為什么我不能對普通變量進行多態(tài)?)
Dereferencing deleted pointers always result in an Access Violation?(取消引用已刪除的指針總是會導致訪問沖突?)
Is pointer comparison undefined or unspecified behavior in C++?(C++ 中的指針比較是未定義或未指定的行為嗎?)
主站蜘蛛池模板: 亚洲午夜电影 | 国产精品久久久久久久久久三级 | 欧美激情久久久久久 | 亚洲欧美中文日韩在线v日本 | 欧美成视频| 欧美日韩在线视频一区二区 | 欧美在线一区二区三区四区 | 亚洲一区二区三区 | 久久草在线视频 | 欧美日韩成人影院 | 国产做爰| 武道仙尊动漫在线观看 | 亚洲一级二级三级 | 久久国内 | 欧美激情a∨在线视频播放 成人免费共享视频 | 久草精品视频 | 欧美日韩一区二区三区在线观看 | 久草久草久草 | av免费看在线 | 成人精品国产一区二区4080 | 久艹网站 | 在线视频 亚洲 | 午夜视频一区二区三区 | 亚洲免费一 | 欧美成人一级 | 一区二区电影 | 精品乱码一区二区 | 在线观看国产视频 | 久久激情视频 | a级在线观看| 成人三级视频在线观看 | 韩国av网站在线观看 | 国产一区欧美一区 | 欧美一级在线视频 | 午夜免费成人 | 91黄色片免费看 | 美女黄色在线观看 | 亚洲日本成人 | 日韩伦理一区二区 | 国内av在线 | 久久伊人精品 |