| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 485 人关注过本帖
标题:求教一下c++ lambda语句
只看楼主 加入收藏
yangboxionga
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2015-5-8
收藏
 问题点数:0 回复次数:1 
求教一下c++ lambda语句
Microsoft Visual C++6.0编的程序   以前在学校电脑里弄得软件
#include <iostream>
//#include <string>
#include <vector>
#include <algorithm>

using namespace std;

void play(vector<int> &a)
{
    for_each( a.begin(),a.end(),[] (int &Element) {cout << Element << " ";} );
    cout << endl;
}
int main()
{
    vector<int> liang;
    liang.push_back(8);
    liang.push_back(89);
    liang.push_back(20);
    liang.push_back(257);

    play(liang);

    sort (liang.begin(),liang.end(),[](int &num1,int &num2) {return (num2 < num1);});

    paly(liang);

    return 0;
}


D:\1\c++\chengxu\hello\hello.cpp(10) : error C2059: syntax error : '['
D:\1\c++\chengxu\hello\hello.cpp(10) : error C2143: syntax error : missing ')' before '{'
D:\1\c++\chengxu\hello\hello.cpp(10) : error C2143: syntax error : missing ';' before '{'
D:\1\c++\chengxu\hello\hello.cpp(10) : error C2065: 'Element' : undeclared identifier
D:\1\c++\chengxu\hello\hello.cpp(10) : error C2059: syntax error : ')'
D:\1\c++\chengxu\hello\hello.cpp(23) : error C2059: syntax error : '['
D:\1\c++\chengxu\hello\hello.cpp(23) : error C2143: syntax error : missing ')' before '{'
D:\1\c++\chengxu\hello\hello.cpp(23) : error C2143: syntax error : missing ';' before '{'
D:\1\c++\chengxu\hello\hello.cpp(23) : error C2065: 'num2' : undeclared identifier
D:\1\c++\chengxu\hello\hello.cpp(23) : error C2065: 'num1' : undeclared identifier
D:\1\c++\chengxu\hello\hello.cpp(23) : error C2059: syntax error : ')'
D:\1\c++\chengxu\hello\hello.cpp(25) : error C2065: 'paly' : undeclared identifier
执行 cl.exe 时出错.


这个是怎么回事,和书里一模一样(除了变量名),求助一下,还是说我的软件不支持?
搜索更多相关主题的帖子: Microsoft include liang 
2015-05-08 21:18
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9008
专家分:53957
注 册:2011-1-18
收藏
得分:0 
还是说我的软件不支持?
--- VC++6 和 Turbo C++ 可以归为同一时期了
2015-05-11 16:20
快速回复:求教一下c++ lambda语句
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014823 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved