创建一个CMap,它保存另一个CMap作为值 [英] Creating a CMap which holds another CMap as a value

查看:268
本文介绍了创建一个CMap,它保存另一个CMap作为值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个CMap,它有一个CString作为键和一个CMap作为一个值。显然,以下是不工作,但我不知道它是如何工作的。

  CMap< CString,LPCSTR,CMap< CString, LPCSTR,int,int>,CMap< CString,LPCSTR,int,int> xyWhatEver;任何人都有一个想法如何使用CMap在c ++中实现这样的数据结构?

$ b


$ b

解决方案

CMap没有复制构造函数。我建议使用STL类,而不是mfc。当然,你可以替换CMap到CMap *,但这将需要额外的分配/释放步骤。

  typedef CMap< CString,LPCSTR ,int,int> tInnerMap; 
CMap< CString,LPCSTR,tInnerMap *,tInnerMap *>地图;


I am trying to create a CMap which has a CString as a key and a CMap as a value. Obviously the following is not working but I have no clue how it is working.

CMap<CString, LPCSTR, CMap<CString, LPCSTR, int, int>, CMap<CString, LPCSTR, int, int>> xyWhatEver;

Anybody has an idea how to implement such a datastructure in c++ using CMap?

解决方案

CMap doesn't have copy constructor. I'd suggest using STL classes instead of mfc. Of course you can replace CMap to CMap*, but this will require additional allocating/freeing steps.

typedef CMap<CString, LPCSTR, int, int> tInnerMap;
CMap<CString, LPCSTR, tInnerMap*, tInnerMap*> map; 

这篇关于创建一个CMap,它保存另一个CMap作为值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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