Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <iterator>
- struct S
- {
- int sum = 0;
- void operator()(int i) { sum += i; }
- };
- int main(void) {
- int a[] = { 1, 2, 3, 4, 5 };
- std::cout << std::for_each(std::begin(a), std::end(a), S()).sum << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement