访问地图数据结构中的结构元素
Accessing elements of structure inside a map datastructure
我有这样的结构,并映射数据结构,如:
#include <map>
struct category {
int id;
std::string name;
};
std::map<int, category> categories;
现在,使用类别,我想显示在结构类别中的元素"名称"。但我无法访问它。有人能帮忙吗?
感谢
您不能访问它是什么意思?
categories[0].name;
应该足够了。
相关文章:
- 使用不带参数的函数访问结构元素
- 访问类lintalizer列表中的结构元素
- 如何为 c++ 的不同变量类型的结构元素创建动态数组?
- 结构元素名称要 cout?
- C++结构元素(成员变量)的数量
- 如何在类中声明静态 const 结构元素
- 在地图中搜索结构元素
- 在C++中传递结构数组 - 被调用函数中不存在结构元素,如何正确传递向量?
- 结构元素C 的枚举
- 将结构元素地址设置为C 中的null(单链接列表)
- OPENCV:为击中创建一个正方形结构元素
- 如何将结构元素传递给异步线程
- C - 基于另一个元素对结构元素进行排序
- 无法从传递到 pthread 的结构中访问结构元素
- 矢量的打印结构元素
- C结构元素对齐(ansi)
- 用3x3结构元素进行两次形态扩张,等于用6x6结构元素进行一次形态扩张
- 创建结构元素的动态数组,然后创建该结构的动态数组.C++
- 访问地图数据结构中的结构元素
- 尝试在文本文件中添加结构元素而不覆盖它