大虾帮忙看看这段C++ set的代码错在何处?

来源:百度知道 编辑:UC知道 时间:2024/07/01 03:58:32
struct cmp
{
bool operator()(const int &a, const int &b)
{
if (a>b) return true;
return false;
}
};

int main()
{
set<int, cmp> T;

set<int, cmp>::iterator it;

for (it=T.begin(); it!=T.end(); it++)
{
printf("%d\n", *it);
}
return 0;
}

在VC里编译不过,不知道怎么回事??
to "xj1985xj": 这个加上头文件就是全部代码。

你既然说了是C++的,那就把printf换成cout啊,然后加上
#include <iostream>
#include <set>
using namespace std;

请把代码全部发上来,让我去VC里编译试试