Video Coming Soon...

Created by Zed A. Shaw Updated 2026-06-19 17:00:40

48: Lambdas

The Code

View Source file ex48.cpp Only

#include <fmt/core.h>
#include <string>

auto make_adder(auto base) {
  return [=](auto a) -> auto {
    return base + a;
  };
}

int main() {
  auto int_adder = make_adder(100);
  auto float_adder = make_adder(23.4f);

  fmt::println("{} + {} = {}", 100, 3, int_adder(4));
  fmt::println("{} + {} = {}", 23.4f, 32.8f, float_adder(32.8f));
}

The Breakdown

line of code
Description.

The Discussion

Blah blah.

Further Study

Previous Lesson Next Lesson

Register for Learn C++ the Hard Way

Register to gain access to additional videos which demonstrate each exercise. Videos are priced to cover the cost of hosting.