C++ lambda function with no argument return 1

Viewed 59

I was writing simple C++ program, while using lambda function, and I got into this situation

std::cout << [](int x = 10) -> int { return (x + 5); } << std::endl; // prints 1

I expected, with no passing argument, this lambda function would return 15, therefore printed result would be 15.

But above lambda function returns 1 instead. Does it mean that the lambda function just worked correctly? Is is some kind of flag value?

0 Answers
Related