C++ 列表根本没有排序

C++ 列表根本没有排序,c++,visual-c++,C++,Visual C++,我正在更新一个列表,然后尝试对列表进行排序,将最高的sVar1放在列表的前面,但它没有这样做,我使用的是6.0 VS while(Iter != m_SomeList.end()) { if((*Iter)->sVar1 == 1) { (*Iter)->sVar1++; } Iter++; } m_SomeList.sort(Descending()); Iter = m_SomeList.begin(); while(It

我正在更新一个列表,然后尝试对列表进行排序,将最高的
sVar1
放在列表的前面,但它没有这样做,我使用的是6.0 VS

while(Iter != m_SomeList.end())
{
    if((*Iter)->sVar1 == 1) 
    {
        (*Iter)->sVar1++;
    }

    Iter++;
}

m_SomeList.sort(Descending());

Iter = m_SomeList.begin();

while(Iter != m_SomeList.end())
    {
        //now display the content of the list
我的降序排序函数

struct Descending : public greater<_LIST_DETAIL*> 
{
    bool operator()(const _LIST_DETAIL* left, const _LIST_DETAIL* right)
    {
        return (left->sVar1 > right->sVar1);
    }
};
struct Descending:public更大
{
布尔运算符()(常量列表详细信息*左,常量列表详细信息*右)
{
返回(左->sVar1>右->sVar1);
}
};
有人能看出哪里出了问题吗


编辑:更新了代码,里面有打字错误…

这简直是一团糟

首先,您不是从
std::greater
派生的,而是直接使用
std::greater
,如:

(psudocode,未编译)

…或者,如果这对您没有好处,可以通过从
std::一元函数
派生来编写您自己的函子:

struct Descending : public unary_function<bool, _LIST_DETAIL>
{
    bool operator()(const _LIST_DETAIL* left, const _LIST_DETAIL* right) const // note const
    {
        return (left->sVar1 > right->sVar1);
    }
};
struct Descending:公共一元函数
{
布尔运算符()(常量列表详细信息*左,常量列表详细信息*右)常量//注释常量
{
返回(左->sVar1>右->sVar1);
}
};
其次,该语言保留了前导下划线后跟大写名称的用法


第三,您使用的是一个已有14年历史的编译器,微软多年前就已经终止了对它的所有支持。更重要的是,按照今天的标准,这是一堆臭烘烘的垃圾。新的时候甚至都不是很好。你需要离开VS6.0

如果不是
left->sVar1>right->sVar1
?看在上帝的份上,离开VS6.0!!注意,后面有一个
while
上,表示以下
{}
中的代码将执行一次。这是一个无限或空循环:
while(Iter!=m_SomeList.end())此外,以下划线开头,后跟大写字母的名称在任何范围内都是保留的。
struct Descending : public unary_function<bool, _LIST_DETAIL>
{
    bool operator()(const _LIST_DETAIL* left, const _LIST_DETAIL* right) const // note const
    {
        return (left->sVar1 > right->sVar1);
    }
};