cpp lambda function 1

cpp lambda function

#include 
using namespace std;

bool isGreater = [](int a, int b){ return a > b; }

int main() {
	cout << isGreater(5, 2) << endl; // Output: 1
	return 0;
}

Here is what the above code is Doing:
1. We are creating a lambda function that takes two integers as parameters and returns a boolean value.
2. We are assigning the lambda function to a variable isGreater.
3. We are calling the lambda function and passing 5 and 2 as arguments.
4. The lambda function returns true because 5 is greater than 2.

Similar Posts