C++ Map Question
- by Wallace
Hi. I'm working on my C++ assignment about soccer and I encountered a problem with map.
My problem that I encountered is that when I stored 2 or more "midfielders" as the key, even the cout data shows different, but when I do a multiplication on the 2nd -second value, it "adds up" the first -second value and multiply with it.
E.g.
John midfielder 1
Steven midfielder 3
I have a program that already reads in the playerPosition. So the map goes like this:
John 1 (Key, Value)
Steven 3 (Key, Value)
if(playerName == a-first && playerPosition == "midfielder")
{
cout << a-second*2000 << endl; //number of goals * $2000
}
So by right, the program should output:
2000
6000
But instead, I'm getting
2000
8000
So, I'm assuming it adds the 1 to 3 (resulting in 4) and multiplying with 2000, which is totally wrong...
I tried cout a-first and a-second in the program and I get:
John 1
Steven 3
But after the multiplication, it's totally different.
Any ideas?
Thanks.