mirror of
https://github.com/Light-City/CPlusPlusThings.git
synced 2026-02-12 06:55:20 +08:00
update
This commit is contained in:
32
modern_C++_30/functionLambda/function.cpp
Normal file
32
modern_C++_30/functionLambda/function.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
//
|
||||
// Created by light on 20-1-11.
|
||||
//
|
||||
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
#include <functional>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
|
||||
map<string, function<int(int, int)>>
|
||||
op_dict{
|
||||
{"+",
|
||||
[](int x, int y) {
|
||||
return x + y;
|
||||
}},
|
||||
{"-",
|
||||
[](int x, int y) {
|
||||
return x - y;
|
||||
}},
|
||||
{"*",
|
||||
[](int x, int y) {
|
||||
return x * y;
|
||||
}},
|
||||
{"/",
|
||||
[](int x, int y) {
|
||||
return x / y;
|
||||
}},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user