我的要求是给定一个字符串作为映射的键,我应该能够检索一个结构。
有人可以为此发布示例代码吗?
例如:
struct
{
int a;
int b;
int c;
}struct_sample;
string1 -> strcut_sample
最佳答案
CMap<CString,LPCTSTR, struct_sample,struct_sample> myMap;
struct_sample aTest;
aTest.a = 1;
aTest.b = 2;
aTest.c = 3;
myMap.SetAt("test",aTest);
...
struct_sample aLookupTest;
BOOL bExists = myMap.Lookup("test",aLookupTest); //Retrieves the
//struct_sample corresponding to "test".
示例来自 MDSN有关 CMap 的更多详细信息。
关于c++ - 字符串->结构CMap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/848551/