Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ArithmeticLambda(const int input1, const int input2, std::function<int(const int, const int)> op)
- {
- std::cout << op(input1, input2) << '\n';
- }
- int main()
- {
- auto add = [](const int lhs, const int rhs) { return lhs + rhs; };
- auto subtract = [](const int lhs, const int rhs) { return lhs - rhs; };
- auto multiply = [](const int lhs, const int rhs) { return lhs * rhs; };
- auto divide = [](const int lhs, const int rhs) { return lhs / rhs; };
- ArithmeticLambda(3, 4, add);
- ArithmeticLambda(3, 4, subtract);
- ArithmeticLambda(3, 4, multiply);
- ArithmeticLambda(6, 3, divide);
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement