godop 2017-03-14 09:32 采纳率: 0%
浏览 1452

c++有关于lambda返回值问题 都是对的。。。

#include
using namespace std;
int f4(){
int a=3,b=4;
auto f= a,b->int{
if(a>b)
return i;
else
return -i;
};
cout<<f(1)<<endl;

}

int main(){
f4();
return 0;
}
//****************为什么上下都是对的*************
#include
using namespace std;
int f4(){
int a=3,b=4;
auto f= a,b{
if(a>b)
return i;
else
return -i;
};
cout<<f(1)<<endl;

}

int main(){
f4();
return 0;
//下面这个应该有问题吧

  • 写回答

1条回答 默认 最新

  • AlbertS 领域专家: 系统编程技术领域 2017-03-14 09:43
    关注

    你指的是什么不对呢?语法吗?这应该是正确的,因为很多元素都是可以省略的
    参考http://blog.csdn.net/albertsh/article/details/58232824

    评论

报告相同问题?