高手看过来,有关algorithm
大家先看下面一段程序,通过下面的过程order数组记录了score数组中的数的大小顺序。
#include <functional>
#include <algorithm>
using namespace std;
float score[2] = {2.0,1.0};
int order[2];
bool cmp(const int &a,const int &b)
{
return score[a] < score[b];
}
int main()
{
int i;
for(i = 0; i < 2; i++)
{
order[i] = i;
}
sort(order,order + 2,ptr_fun(cmp));
return 0;
}
但是我在vc6的atl做的一个com组件中用类似的技术,order数组却没有按照预想的记录下score数组的大小顺序,难道stl不能在atl中用吗?
怎么回事呢?