gpt4 book ai didi

c++ - 如何访问 CMap 中的元素?

转载 作者:搜寻专家 更新时间:2023-10-31 01:34:53 24 4
gpt4 key购买 nike

有人能告诉我如何根据特定键获取特定元素吗?假设我有一个 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);

如果 foundtrue,则 ret 就是您的答案。

关于c++ - 如何访问 CMap 中的元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38428985/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com