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

c++ - 如何從指向向量的指針訪問向量的內(nèi)容?

How to access the contents of a vector from a pointer to the vector in C++?(c++ - 如何從指向向量的指針訪問向量的內(nèi)容?)
本文介紹了c++ - 如何從指向向量的指針訪問向量的內(nèi)容?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時送ChatGPT賬號..

我有一個指向向量的指針.現(xiàn)在,如何通過指針讀取向量的內(nèi)容?

I have a pointer to a vector. Now, how can I read the contents of the vector through pointer?

推薦答案

解決方案有很多,以下是我想到的幾個:

There are many solutions, here's a few I've come up with:

int main(int nArgs, char ** vArgs)
{
    vector<int> *v = new vector<int>(10);
    v->at(2); //Retrieve using pointer to member
    v->operator[](2); //Retrieve using pointer to operator member
    v->size(); //Retrieve size
    vector<int> &vr = *v; //Create a reference
    vr[2]; //Normal access through reference
    delete &vr; //Delete the reference. You could do the same with
                //a pointer (but not both!)
}

這篇關(guān)于c++ - 如何從指向向量的指針訪問向量的內(nèi)容?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Difference between std::reference_wrapper and simple pointer?(std::reference_wrapper 和簡單指針的區(qū)別?)
Difference between const. pointer and reference?(常量之間的區(qū)別.指針和引用?)
Meaning of *amp; and **amp; in C++(*amp; 的含義和**amp;在 C++ 中)
Why can#39;t I do polymorphism with normal variables?(為什么我不能對普通變量進(jìn)行多態(tài)?)
Dereferencing deleted pointers always result in an Access Violation?(取消引用已刪除的指針總是會導(dǎo)致訪問沖突?)
Is pointer comparison undefined or unspecified behavior in C++?(C++ 中的指針比較是未定義或未指定的行為嗎?)
主站蜘蛛池模板: 夜夜骑天天干 | 在线观看a视频 | 亚洲免费看片 | 久久综合影院 | 亚洲成人免费在线 | 九九色影院 | 国产一区二区久久 | 一区二区三区中文字幕 | 欧美性生交xxxxx | 天堂中文资源在线 | 成人免费看片98欧美 | 久草国产视频 | 日韩精品国产精品 | 亚洲精品无 | a毛片在线观看 | 欧美日韩中文字幕 | 天天爱综合 | 在线观看免费av网站 | 成人三级在线 | 国产精品911 | 福利视频二区 | 中文字幕一区在线观看 | 精品视频一区二区三区 | 国产欧美日韩一区二区三区 | 日韩成人高清 | 黄色免费毛片 | 黄色网免费| 亚洲成人av在线播放 | 国产免费黄色 | 亚洲国产欧美日韩在线 | 一级黄色片在线观看 | 18成人免费观看网站 | 成人三级视频在线观看 | 久久久影院 | 亚洲综合激情网 | 免费视频一区二区 | av网站导航| 久草青青草 | 狠狠干在线视频 | 日韩精品一 | 综合久|