有人可以启发我有关如何基于特定键来获取特定元素的问题。假设我有一个CMap ButtonProp;现在我想访问提供的任何int值的属性,该怎么做?PS第一次使用CMap。“ ButtonProp.Lookup(int)”是否足够?
您基本上有两个选择:
如果您知道该元素存在,则可以使用CMap::operator[]
:
否则,您应该使用CMap::Lookup
,但是用法与您的问题中的用法不同。
假设您从
CMap<int,int,CPoint,CPoint> myMap;
myMap.InitHashTable(257);
要找到对应于3的元素,您可以使用
myMap[3]
或者
CPoint ret;
bool found = myMap.Lookup(3, ret);
如果found
是true
,那么ret
是您的答案。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句