我在阅读 jiangly 的代码学会了新的函数定义方法:
void solve() {
auto calc = [&] (int x) {
return x * x;
};
cout << calc(5) << endl;
function<int(int)> dfs = [&] (int x) {
if(!x) return 1;
return x * dfs(x - 1);
};
cout << dfs(5) << endl;
}
GCC 9.3.0 c++14 编译通过
那在 NOI 系列比赛中建议用这种写法吗。