q*******p 发帖数: 39 | 1 有1道题请教大家
1. 实现 Reduce function using templates. The Reduce 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, Reduce(, std::plus()) should
calculate ((((1+2)+3)+4)+5).
class NotEnoughElements {};
template
typename Container::value_type
Reduce(const Container& c, Function fn) throw (NotEnoughElements)
{
实现
} |
|