I have never used C ++ functions before, and so I'm just trying to figure out how they work.
eg. suppose we have this class of functors
class MultiplyBy { private: int factor; public: MultiplyBy(int x) : factor(x) { } int operator () (int other) const { return factor * other; } };
Using this as it is clear to me:
MultiplyBy mult_3(3); int x = mult_3(100);
The Obviosuly constructor of the MultiplyBy is invoked with argument 3.
But in the following case, how is a constructor called with a value in an array?
int array[5] = {1, 2, 3, 4, 5}; std::transform(array, array + 5, array, MultiplyBy(3));
source share