相关疑难解决方法(0)

使用STL排序功能对列表进行排序

我正在尝试按降序排序列表(类的一部分)包含a的项目struct,但它不编译:

错误:'__last - __first'中'operator-'不匹配

sort(Result.poly.begin(), Result.poly.end(), SortDescending());
Run Code Online (Sandbox Code Playgroud)

这是SortDescending:

struct SortDescending
{
    bool operator()(const term& t1, const term& t2)
    { 
        return t2.pow < t1.pow; 
    }
};
Run Code Online (Sandbox Code Playgroud)

谁能告诉我什么是错的?

c++ sorting stl list

22
推荐指数
2
解决办法
2万
查看次数

标签 统计

c++ ×1

list ×1

sorting ×1

stl ×1