[英]accessing information in a vector of pointers
I currently have a vector of pointers, how would I cout
the information at a particular pointer in the vector? 我现在有一个指针的向量,我怎么会
cout
在载体中的特定指针的信息?
I am looking at how to deference the address stored in the vector. 我正在研究如何尊重存储在向量中的地址。
vector<MyType*> addressList;
cout<<(*(addresssList[i])).Data ; //assuming Data is the content you want to output and you would like to output the content addressed by the `ith` element.
std::vector<int*> ints;
for ( auto cur = ints.begin(); cur != ints.end(); ++cur)
{
std::cout << (*(*cur)) << "\n";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.