I've got a file structured like this:
A 123456 0
G 123456 5
A 235334 0
B 123456 2
Each piece of information is being stored like so:
temp.code >> temp.personid >> temp.data
I've stored this information in a Vector
ifstream fin("test.txt");
vector<TestClass> test;
TestClass temp;
string line;
while (getline(fin, line)) {//.. test.push_back(temp);}
A given personid can come up numerous times within the file. What I want to do is iterate through the vector and group the repetitions into a single class object per personid, my goal is that I want sum the data for each particular object such that the output for the file above would be:
123456 : 7
235334 : 0
What would be an elegant way to approach this?
Thanks