我班上有这个enum声明:
const enum METHODS{
Write,
Save,
Update,
Delete
};
Run Code Online (Sandbox Code Playgroud)
但是当我检索到我的枚举的价值时; 我得到-842150451
了所有方法的这个值.
它应该是0,1,2,3对吗?
请帮我解决这个问题.
我把我的枚举值放入 map<LPCTSTR, long> m_methodMap
m_methodMap[_T("Save")] = Save;
same with other methods
我这样检索它:
cout << "Values " << m_methodMap.find(sMethodName)->second; // where sMethodName is the methods
std::map<LPCTSTR, long>
是垃圾.LPCTSTR
是char*
(或wchar_t*
)的typedef ,这意味着映射根据指针的值比较键,而不是存储在其中的字符串.你可能意味着std::map<std::basic_string<TCHAR>, METHODS>
.不要在C++中使用C数据结构.
归档时间: |
|
查看次数: |
158 次 |
最近记录: |