jweinst1
9/2/2016 - 5:58 PM

basic lambda examples in C++

basic lambda examples in C++

#include <iostream>

//lambda examples for C++

int main() {
	auto add = [](int a, int b){
		return a + b;
	};
    std::cout << add(3, 4) << std::endl;
    //7
    auto get = [](int a[], int index){
    	return a[index];
    };
    int f[] = {0, 1, 2};
    std::cout << get(f, 1) << std::endl;
    //1
}