首页 新闻 会员 周边 捐助

vc6.0中set容器使用不了函数对象

0
[已关闭问题] 关闭于 2013-07-04 12:27

#include <iostream>
#include <set>
#include <functional>
using namespace std;


void Print(set<int, greater<int>> setInt)
{
 set<int, greater<int>>::iterator it;

 for (it = setInt.begin(); it != setInt.end(); it++)
 {
  cout << *it <<  endl;
 }
}

int main(int argc, char *argv[])
{
 set<int, greater<int>> setInt;

 setInt.insert(3);
 setInt.insert(1);
 setInt.insert(2);
 setInt.insert(1);

 Print(setInt);

 return 0;
}

C:\Users\asus\Desktop\test\setMultiset\main.cpp(7) : error C2146: syntax error : missing ',' before identifier 'setInt'
C:\Users\asus\Desktop\test\setMultiset\main.cpp(7) : error C2065: 'setInt' : undeclared identifier
C:\Users\asus\Desktop\test\setMultiset\main.cpp(7) : error C2143: syntax error : missing ',' before ')'
C:\Users\asus\Desktop\test\setMultiset\main.cpp(8) : error C2143: syntax error : missing ';' before '{'
C:\Users\asus\Desktop\test\setMultiset\main.cpp(9) : error C2039: 'iterator' : is not a member of 'greater<int>'
C:\Users\asus\Desktop\test\setMultiset\main.cpp(9) : error C2146: syntax error : missing ',' before identifier 'it'
C:\Users\asus\Desktop\test\setMultiset\main.cpp(9) : error C2065: 'it' : undeclared identifier
C:\Users\asus\Desktop\test\setMultiset\main.cpp(9) : error C2143: syntax error : missing '>' before ';'
C:\Users\asus\Desktop\test\setMultiset\main.cpp(11) : error C2143: syntax error : missing ')' before ';'
C:\Users\asus\Desktop\test\setMultiset\main.cpp(11) : error C2059: syntax error : ')'
C:\Users\asus\Desktop\test\setMultiset\main.cpp(12) : error C2143: syntax error : missing ';' before '{'
C:\Users\asus\Desktop\test\setMultiset\main.cpp(14) : error C2143: syntax error : missing ';' before '}'
C:\Users\asus\Desktop\test\setMultiset\main.cpp(15) : error C2143: syntax error : missing ';' before '}'
C:\Users\asus\Desktop\test\setMultiset\main.cpp(17) : error C2146: syntax error : missing ',' before identifier 'argv'
C:\Users\asus\Desktop\test\setMultiset\main.cpp(17) : error C2065: 'argv' : undeclared identifier
C:\Users\asus\Desktop\test\setMultiset\main.cpp(17) : error C2059: syntax error : ']'
C:\Users\asus\Desktop\test\setMultiset\main.cpp(18) : error C2143: syntax error : missing ';' before '{'
C:\Users\asus\Desktop\test\setMultiset\main.cpp(19) : error C2146: syntax error : missing ',' before identifier 'setInt'
C:\Users\asus\Desktop\test\setMultiset\main.cpp(19) : error C2143: syntax error : missing '>' before ';'
C:\Users\asus\Desktop\test\setMultiset\main.cpp(29) : error C2143: syntax error : missing ';' before '}'
C:\Users\asus\Desktop\test\setMultiset\main.cpp(30) : error C2143: syntax error : missing ';' before '}'
C:\Users\asus\Desktop\test\setMultiset\main.cpp(30) : fatal error C1001: INTERNAL COMPILER ERROR
        (compiler file 'Y?, line 1)
         Please choose the Technical Support command on the Visual C++
         Help menu, or open the Technical Support help file for more information
Error executing cl.exe.

为什么set使用不了greater等函数对象,去掉greater程序正确运行,一加上就有错误,求大神解答?
我是在vc6.0中运行的

fun~的主页 fun~ | 菜鸟二级 | 园豆:204
提问于:2013-07-04 11:41
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册