error: no matching function for call to
来源:互联网 发布:国家燃烧知乎 编辑:程序博客网 时间:2024/05/01 18:45
今天用c++标准模板库(STL)中的sort算法给一个vector<pair<int,double>>对象排序时遇到了题目中的编译时错误:(问题虽然简单,却让我弄了整整一下午)
error: no matching function for call to'sort(__gnu_cxx::__normal_iterator<std::pair<int,double>*
note: candidates are: void std::sort(_RandomAccessIterator,_RandomAccessIterator, _Compare) ......
程序是这样的:
fourdct.h
boolPhasePairLess(pair<int,double>p1,pair<int,double>p2);//这是fourdct类的成员函数。
fourdct.cpp
vector<pair<int,double>> phasePairVector;
....
sort(phasePairVector.begin(),phasePairVector.end(),PhasePairLess);
boolFourDCT::PhasePairLess(pair<int,double>p1,pair<int,double> p2)
{
}
错误的原因是比较函数PhasePairLess应当是static的。将头文件中的函数声明改为:
static boolPhasePairLess(pair<int,double>p1,pair<int,double> p2);
编译通过。注意,cpp文件中不用static。
- error: no matching function for call to
- error: no matching function for call to 'MainWindow::connect(*&, ...)
- no matching function for call to ‘transform
- no matching function for call to ‘transform
- no matching function for call to 'sort(...),
- error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)
- error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)
- error: no matching function for call to 'std::basic_ifstream<char>::open(std::string&)
- error: no matching function for call to 'std::exception:exception(const char[16])'
- C++中错误no matching function for call to transform
- [c++]no matching function for call to ‘sort(…)......
- 【C++错误处理】no matching function for call to transform
- 【C++错误处理】no matching function for call to transform
- No matching function call to 'pthread_create'
- C++常见错误之:no matching function for call to transform
- 【求助】 no matching function for call to `strcpy(std::string&, char*&)'
- cocos2d-2.1beta3-x-2.1.1 "no matching function for call to..."
- C++ STL string 大小写转换时的 no matching function for call to ‘transform 错误
- Java synchronized详解
- C/C++ 微软面试题 -链表
- IOS 生成pem证书方法
- 下一代的APACHE HADOOP MAPREDUCE : YARN
- pthread_create如何传递多个参数
- error: no matching function for call to
- 我们玩新浪微博
- 字典树——Message Flood
- Spring注解@Component、@Repository、@Service、@Controller区别
- 受限玻尔兹曼机(RBM)学习笔记(七)RBM 训练算法
- 网络广告js备忘【1】
- WinAPI: SetWindowsHookEx - 设置钩子
- POJ 2352 Stars (线段树&想法题)
- cocos2d-x给CCTableView加入下拉滚动条