赞
踩
#include <iostream> using namespace std; int main(){ // c++ lambda // int c; int x=2,y=3; // 传入形参 auto test = [] (int x,int y){return x+y;}; // 传入 引用 auto train = [] (int &x,int &y){ cout<<x<<endl<<y<<endl;return x+y;}; // 传入指针 auto t = [] (int *x,int *y){ cout<<x<<endl<<y<<endl;return *x+*y;}; cout<<test(1,2)<<endl; cout<<train(x,y)<<endl; cout<<t(x,y)<<endl; return 0; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。