作成した整数とクラスのマップがあります。ここで、リスト内の各要素の整数を変更する必要があります。
私はこのようにsthについて考えました:
std::map<int, Product> ProductList; //This is filled somewhere and can be accessed in my function
void remove()
{
std::map<int, Product>::iterator it = ProductList.begin();
for(; it != ProductList.end(); it++)
{
it->first = it->first - 1;
}
}
今、私のコンパイラは言う
エラー: 読み取り専用メンバー '
std::pair<const int, Product>::first
' の割り当て
私は何を間違っていますか?1
各要素の整数から減算する必要があります。