I'm trying to use std::accumulate to multiply objects but can't get it done. I get the error "cannot convert Acc to int" in accumulate (BCB5). Anybody knows what's wrong?
Code:struct Acc { Acc(int x) : x(x) {} friend int operator*(const Acc& lhs, const Acc& rhs) { return lhs.x * rhs.x; } int x; }; int main() { Acc acc[] = { { 1 }, { 2 }, { 3 } }; std::cout << std::accumulate( acc, acc + sizeof acc / sizeof *acc, 1, std::multiplies<Acc>())); }