fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. auto x = 0, y = 0;
  6. auto lambda = [x, &y]() { std::cout << x << ' ' << y; };
  7. x = 1, y = 1;
  8. {
  9. auto x = 27, y = 2;
  10. lambda(); // still outputs: 0 1
  11. }
  12. return 0;
  13. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
0 1