Search:
Forum
General C++ Programming
Using a map to keep a total?
Using a map to keep a total?
Sep 25, 2010 at 4:43pm UTC
Gajewa469
(10)
I am trying to figure out a way to use maps to keep a total number of items.
I was using arrays before
total[x] = total[x] + (function to add another
int
);
Now I made total a map, but have no idea how to get the same result.
Gives me an error.
Any help would be greatly appreciated.
Sep 25, 2010 at 5:19pm UTC
LB
(13399)
If you just want to keep a total count of things, why do you need an array, map, or anything else besides just one value? I am not sure I understand fully what you want to do here, could you explain more?
Sep 25, 2010 at 5:22pm UTC
Gajewa469
(10)
I am using it to deal cards, and it needs to be able to add another card on top of it.
There are up to 7 players so I need to be able to keep track.
Sep 25, 2010 at 5:32pm UTC
LB
(13399)
I think you want more of a vector than a map.
http://www.CPlusPlus.com/vector
A vector makes more sense than a map because maps use a key to get to the value whereas vectors are more like an expandable array-ish thing.
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs