我在Windows 10上使用VS2008。 我有这个功能的问题,希望你能帮助我
void CPythonNetworkStream::AppearShopSign(DWORD dwVID, std::string stSign) {
if (stSign.empty())
for (auto it = m_mapShopSign.begin(); it != m_mapShopSign.end(); ++it)
if (dwVID == it->first)
stSign = it->second;
// LogBoxf("AppearShopSign: %u-%s", dwVID, stSign.c_str());
PyCallClassMemberFunc(m_apoPhaseWnd[PHASE_WINDOW_GAME], "BINARY_PrivateShop_Appear", Py_BuildValue("(is)", dwVID, stSign.c_str()));
}
错误消息
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2440: 'initializing' : cannot convert from 'std::_Tree<_Traits>::iterator' to 'int'
error C2678: binary '!=' : no operator found which takes a left-hand operand of type 'int' (or there is no acceptable conversion)
error C2227: left of '->first' must point to class/struct/union/generic type
答案 0 :(得分:1)
自c ++ 11标准以来支持auto
关键字,而visual-studio 2008无法使用该标准。
要修复它,请使用显式类型:
for (std::map<DWORD,std::string>::iterator it = m_mapShopSign.begin();
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
it != m_mapShopSign.end();
++it)
答案 1 :(得分:0)
如上所述,auto
是在{+ 3}}的C ++ 11中引入的。在C ++ 11之前,它用于声明具有自动存储持续时间的局部变量。