如何在C ++中编写3d映射? [英] How to write 3d mapping in C++?

查看:125
本文介绍了如何在C ++中编写3d映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能告诉我怎么能写多维地图。对于二维映射,我做了以下操作:

  map< string,int&员工
员工[person1] = 200;

我正在尝试使用类似于以下内容的三维映射。

  map< string,string,int>雇员; 
员工[person1,age] = 200;你能告诉我正确的方法吗?









$ b < b $ b

有没有办法我可以初始化所有的地图元素为0?就像在数组上,我们可以说 int array [10] = {0};

解决方案

您需要创建这样的地图。

  map< string,map< string,int& >雇员; 
employees [person1] [age] = 200;


Can you please tell me how I can write multidimensional map. For two dimensional map, I did the following:

map<string, int> Employees
Employees["person1"] = 200;

I was trying to use something similar to following for 3d mapping.

map<string, string, int> Employees;
Employees["person1", "age"] = 200;

Can you please tell me the correct way to do this?

and Is there a way I can initialize all the map elements to be 0 ? Just like on a array we can say int array[10]={0};

解决方案

You need to create map of maps like that.

map<string, map<string, int> > employees;
employees["person1"]["age"] = 200;

这篇关于如何在C ++中编写3d映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆