久久久久久久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)容?的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時(shí)送ChatGPT賬號..

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

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

推薦答案

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

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++ 中的指針比較是未定義或未指定的行為嗎?)
主站蜘蛛池模板: 日韩欧美高清dvd碟片 | 国产成人在线视频免费观看 | 欧美日韩高清在线观看 | 国产精品一区视频 | 午夜在线观看视频 | 精品国产综合 | 久草色视频 | 色婷婷综合在线观看 | 日韩中文字幕在线观看视频 | 成人深夜福利网站 | 九色网址| 狠狠干天天干 | 久久久久免费观看 | 精品久久久一区 | 久久精品亚洲精品国产欧美 | 天堂网中文字幕在线观看 | 亚洲免费影院 | 99久热在线精品视频观看 | 国产在线资源 | 久久一二 | 欧美日韩久 | 欧洲一区二区视频 | 欧美成人在线免费 | 成人精品免费视频 | 久久国产精品视频 | 国产精品久久久久久久久免费 | 中文字幕精品一区二区三区精品 | 久久久久国产精品www | 日韩一区二区免费视频 | 国产精品3区 | 欧美h视频 | 欧美日韩国产一区二区三区 | 午夜欧美日韩 | 夜夜骑首页 | 成人a视频片观看免费 | 在线观看亚洲一区二区 | 99久久精品国产一区二区三区 | 日韩一区二区三区在线观看视频 | 性做久久久久久免费观看欧美 | 久久精品网| 毛色毛片免费看 |