c++ - 存储指向 map 中包含的对象的指针

标签 c++ pointers stl reference dictionary

我想知道这段代码是否真的会存储一个指向由映射管理的对象的指针:

std::map<std::string,MapType> map;
MapType* typePointer;

typePointer = map[someKey];

最佳答案

typePointer = &map[someKey];

关于c++ - 存储指向 map 中包含的对象的指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10765082/

相关文章:

c++ - C 到 C++ : Transitioning from one language to the other

c++11 foreach 语法和自定义迭代器

c - 增加枚举 char[ ] 的指针

c - C 中的数组指针与常规指针

c++ - C++ STL 数组的迭代器大小

C++ 从指针生成函数

python - C++(LAPACK、sgels)和Python(Numpy、lstsq)结果的区别

c++ - 不同语言的 MSVC++ 异常 0x80000003

c++ - 填充指向 vector 元素的指针的无序队列

c++ - 分配 vector 时,它们使用堆上的内存还是堆栈上的内存?