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

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

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

問題描述

限時送ChatGPT賬號..

我在函數聲明中多次發現這些符號,但我不知道它們是什么意思.

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];
}

推薦答案

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

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模板網!

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

相關文檔推薦

Difference between std::reference_wrapper and simple pointer?(std::reference_wrapper 和簡單指針的區別?)
Difference between const. pointer and reference?(常量之間的區別.指針和引用?)
How to access the contents of a vector from a pointer to the vector in C++?(c++ - 如何從指向向量的指針訪問向量的內容?)
Why can#39;t I do polymorphism with normal variables?(為什么我不能對普通變量進行多態?)
Dereferencing deleted pointers always result in an Access Violation?(取消引用已刪除的指針總是會導致訪問沖突?)
Is pointer comparison undefined or unspecified behavior in C++?(C++ 中的指針比較是未定義或未指定的行為嗎?)
主站蜘蛛池模板: 五月天视频 | 亚洲天堂网址 | 99久久精品国产一区二区三区 | 欧美激情视频一区二区三区 | 毛片在线观看网站 | 国产欧美综合一区二区三区 | 九色在线观看 | 精品一区二区免费视频 | 怡红院亚洲 | 日本三级大片 | 丰满岳乱妇一区二区 | a在线观看 | 久久久91 | 日韩在线免费视频 | 中文字幕第一区 | 久久久一区二区 | 美女免费网站 | 天堂中文资源在线 | 欧美激情啪啪 | 中文字幕在线免费看 | 免费观看一区二区 | 国产日韩欧美在线观看 | 一级免费看 | 久久精品一区二区三区四区五区 | 亚洲网站在线观看 | 久久成人国产 | 日韩毛片免费看 | 午夜免费网站 | 韩国三级中文字幕hd久久精品 | 天天干干干 | 久久久网 | 欧美区一区二 | 午夜视频免费看 | 欧美日韩在线不卡 | 欧美三级又粗又硬 | 日韩小视频| 午夜视频免费观看 | 中文字幕免费在线看线人动作大片 | 久久中文视频 | 福利视频一区二区 | 成人午夜|