#include <functional> int main() { std::function<int()> fn[100]; for( int i = 0; i < 100;i++ ) fn[i] = [=]() {return i; }; for( int i = 0; i < 100; i++ ) printf( "%d\n", fn[i]() ); return 0; } //result: //0~99 1: std::function<int()> fn[100] 等于缩写了下面的: typedef int (*TypeFn)(); TypeFn fn[100];
时间: 2024-12-14 06:05:16