C++中的map

  • c++中的map类型变量不能为const类型
  • 示例
struct INST{
    string name;
    string type;
    string func;
};

map<string, INST> transTable = {    //can not be const
    {"000000000000",{ .name="sll", .type="R", .func="逻辑左移" }},
    {"000000000011",{ .name="sra", .type="R", .func="算术右移"  }}
};
  • 同string类型一样,map类型也有find方法,用来查找key是否存在。
posted @ 2020-02-14 19:36  friedCoder  阅读(158)  评论(0编辑  收藏  举报