如何在c ++数组中使用字符串索引(如php)?

Som*_*ser 5 c++ arrays

如何在c ++数组中使用字符串索引(如在php中)?

sth*_*sth 20

您可以使用std::map获取关联容器,您可以在其中通过字符串索引查找值.类似的地图std::map<std::string, int>会将整数值与std::string查找键相关联.