dimanche 27 juin 2021

Why is the map value not updating?

I have this free function in my code :

void changeRanks(int n, map<int, double>& id_rank_map)
{
  cout << "n : " << n << endl;
  
  for(auto itr : id_rank_map)
  {
    itr.second = double(1) / double(n);
  }
}

I've verified that 'n' is not 0, but still each value in 'id_rank_map' is 0.00 even after the execution of the line inside the for loop, when accessed from the 'main' function.

How do I update this?

Aucun commentaire:

Enregistrer un commentaire