Can you "reference" variables?

(Title is a poor description - not talking about reference parameters, but not really sure what word to use to describe what I'm looking for.)

I'm writing a program that reads a set of data from an input file - 2 initials and a number of hours worked. A single set of initials can have multiple records or a single one, but the hour values from all records need to be added into one. Is there a way to make my program recognize that the variable is either changing or staying the same, and take an appropriate action either way?

Alternatively, if somebody has a totally different way to start this problem, I'd be happy to hear it. This is just what I happened to think of.
What you're looking for is a map:

1
2
3
map<string,int> compressedRecords;
[...]
foreach(record,records)compressedRecords[record.initials]+=record.hoursWorked;


See:
http://www.cplusplus.com/reference/stl/map/
Topic archived. No new replies allowed.