fork download
  1. #include <iostream>
  2.  
  3. class A {
  4. private:
  5. int m_int;
  6. public:
  7. void foo() {
  8. int a = 1;
  9. int b = 2;
  10. int c = 3;
  11. float f = 3.14f;
  12. std::string s("Something");
  13.  
  14. const auto f1 = [=] () {
  15. // use only a, b, c
  16. int d = a + b + c;
  17.  
  18. const auto f2 = [=] () {
  19. // use f, s and also d
  20. std::cout << f << s << d ;
  21. };
  22. f2();
  23. };
  24.  
  25. f1();
  26. }
  27. };
  28.  
  29. int main() {
  30. A a;
  31. a.foo();
  32. return 0;
  33. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
3.14Something6