any idea on how to do it for template? thanks
For example, Combine(<list containing 6,3,1,9,7>, std::plus<int>())
should calculate ((((6+3)+1)+9)+7).
Combine(const Container& c, Function fn) throw (NotEnoughElements)
{
your code goes here
}
any idea on how to do it for template? thanks
For example, Combine(<list containing 6,3,1,9,7>, std::plus<int>())
should calculate ((((6+3)+1)+9)+7).
Combine(const Container& c, Function fn) throw (NotEnoughElements)
{
your code goes here
}
returnstd::accumulate(c.begin()+1, c.end(), *(c.begin()), fn);
(Error handling is left as exercise for OP and reader.)