sort等库函数不能调用class方法的问题

来源:互联网 发布:小米快盘数据迁移 编辑:程序博客网 时间:2024/06/14 19:07
class solution{pulbic:    bool cmp(int,int){};    void myf(vector<int>&nums)    {        sort(nums.begin(),nums.end(),cmp);//此处的leetcode等编译器提示invalid use of non-static member function,VS提示:应输入2个参数,却提供了3个    }       }

首先从原理上分析这个错误的原因:

0 0
原创粉丝点击