次のコードに混乱しています。なぜ正常にコンパイルできないのですか?
class Test {
public:
int GetValue( int key ) const
{
return testMap[key];
}
map<const int, const int> testMap;
};
常にコンパイル エラーが発生します。
error C2678: binary '[': no operator found which takes "const std :: map <_Kty,_Ty>" type of the left operand operator (or there is no acceptable conversion).
const 修飾子をどこにでも配置しようとしましたが、それでも合格できませんでした。理由を教えてください。