我使用VS2008在Windows 10 我有這個功能的問題,希望你能幫助我使用`auto`產生錯誤C4430:缺少類型說明符 - 假定爲int。注意:C++不支持默認int
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
VS 2008不支持'auto'類型說明符。 – LogicStuff
'auto it'不支持VC++ 2008.您需要升級到其中一個最新版本。 –
@LogicStuff它可能確實支持'auto'的原始C含義,但這不是OP所嘗試使用的。 –