Skip to content
Quiz · Functions · lesson 12 of 13

Quiz — what the lambda captures

What does the program print?

C++
#include <iostream>

int main() {
    int x = 1;
    auto get = [x]() { return x; };
    x = 5;
    std::cout << get() << ' ' << x;
}

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way