[Cs3] Question from CS3
Mikhail Nesterenko
mikhail at cs.kent.edu
Fri Sep 29 11:48:49 EDT 2023
>
> You had asked me to email you in class about the name of the () operator.
it is called, reasonably enough, a "function call operator"
> I also had a question about the accumulate() algorithm that we went over in class. Given:
>
> accumulate(beginRange, endRange, initialValue, callback)
>
> The notes say that accumulate invokes the callback with two
> arguments, first is accumulator. Does this mean that the
> initialValue is the first argument passed to the accumulate
> algorithm, and the second argument is the first element in
> beginRange? Then on subsequent iterations, initialValue continues to
> accumulate the values of the next elements in the range based on how
> the callback is defined?
An interesting thing is that the initValue and first parameter of the
callback do not have to be the same type as the elements of the
range. This is shown in the example here:
http://antares.cs.kent.edu/~mikhail/classes/cs3/Examples/STLAlgorithms/Introduction/stringAccumulate.cpp
The first argument/init value type is "string", the second argument is "char"
Thanks,
--
Mikhail
More information about the cs3
mailing list