fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <functional>
  4. #include <algorithm>
  5.  
  6. struct MyClass {
  7. void fun(int b, int c) const {
  8. std::cout << a << " " << b << " " << c << std::endl;
  9. }
  10. MyClass(int _a) : a(_a) {}
  11. private:
  12. int a;
  13. };
  14.  
  15. int main() {
  16. std::vector<MyClass> v {10, 20, 30};
  17. std::for_each(v.begin(), v.end(), [](const MyClass& m) { m.fun(3, 7); });
  18. return 0;
  19. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
10 3 7
20 3 7
30 3 7