vector<double> data; /* do something with data */ double vsum = 0; accumulate(data.begin, data.end(), vsum); /* now vsum contains the sum of the elements in the vector */ list<double> salaries; /* do something with salaries */ double lsum = 0; accumulate(salaries.begin(), salaries.end(), lsum); /* now lsum contains the sum of the elements in the list */