有人能告诉我如何根据特定键获取特定元素吗?假设我有一个 CMap ButtonProp; 现在我想访问提供的任何 int 值的属性,该怎么做? 附言第一次使用 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
就是您的答案。
关于c++ - 如何访问 CMap 中的元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38428985/