1 2 3 4 5 6 7
int f(Money x, Money y) { return x.m + y.m; } ... double sum = accumulate(money.begin(), money.end(), 0, f)/money.size(); ...