【发布时间】:2013-05-31 14:17:00
【问题描述】:
请告诉我代码有什么问题以及我应该更改什么来修复它(我收到编译错误):
#include <algorithm>
#include <cstring>
using namespace std;
const int MMAX = 1000001;
//--------------------------------------------------------------------------------------------
inline bool comp(int &A, int &B) {
if (A < B) return true;
return false;
}
template<typename _CompareFunction>
struct myHeap { // min-heap
_CompareFunction cmp;
};
//--------------------------------------------------------------------------------------------
myHeap< comp > H;
int main() {
}
非常感谢!
编辑: 编译错误:
heap_minimal.cpp:19:15: error: type/value mismatch at argument 1 in template parameter list for ‘template<class _CompareFunction> struct myHeap’
heap_minimal.cpp:19:15: error: expected a type, got ‘comp’
heap_minimal.cpp:19:18: error: invalid type in declaration before ‘;’ token
(用 C++11 编译)
【问题讨论】:
-
把你要问的代码放在这个网站上。
-
没有人会阅读整个存储库。请将代码放在这里并将它产生的错误告诉我们,以便我们为您提供帮助。 sscce.org
-
并粘贴编译器错误
-
我已经编辑了 OP 的帖子添加了代码,希望没问题...
-
你想完成什么?
标签: c++ class function typename