Implement the Combine function using templates
- by gkid123
any idea on how to do it for template? thanks
Implement the Combine function using templates. The Combine fn applies a
function of two arguments cumulatively to the items of an STL container,
from begin() to end(), so as to reduce the sequence to a single value.
For example, Combine(<list containing 6,3,1,9,7>, std::plus<int>())
should calculate ((((6+3)+1)+9)+7).
class NotEnoughElements {};
template <typename Container, typename Function>
typename Container::value_type
Combine(const Container& c, Function fn) throw (NotEnoughElements)
{
your code goes here
}