Lambda Functions

Lambda expressions are anonymous functions that can be used inline.

#include <iostream>
using namespace std;

int main() {
  auto add = [](int a, int b) { return a + b; };
  cout << add(2, 3);
}

Useful for short, functional-style programming, especially with STL algorithms.

← Prev