有:
std::map<const int, float> m_areaCost;
我正在尝试编译以下内容:
inline float getAreaCost(const int i) const {
return m_areaCost[i];
}
这导致以下错误:
error C2678: binary '[' : no operator found which takes a left-hand operand of type 'const std::map<_Kty,_Ty>' (or there is no acceptable conversion)
我曾经认为当我们调用时[elementId]
我们获取元素值或默认元素值,所以我想知道这种简单的情况如何导致编译错误?