I have problem with compilation of multiple source files, g++
reports that it can't found matched methods in constructor of
Pool.cpp (see below).
/******************* BinaryHeap.h **********************/
template //K = key, D = data.
class BinaryHeap {
public:
typedef int (*compareTo)(const K src, const K dst);
BinaryHeap(int size, compareTo ct);
};
/********************** Pool.h ************************/
#include "BinaryHeap.h"
class Pool {
public:
Pool(int size);
private:
typedef struct { ...} Key;
typedef BinaryHeap tpool;
static int compareKey(const Key* src, const Key* dst);
tpool* e_pool;
};
/******************* Pool.cpp ***********************/
Pool::Pool(int size) {
e_pool = new tpool(size, &RRTPool::compareKey); //<---- error here
}
int Pool::compareKey(const Pool::Key* src, const Pool::Key* dst) {
return ...;
}
/**************** end of Pool.cpp ********************/
The error message is:
error: no matching function for call to `
BinaryHeap::BinaryHeap(int&, int (*)(const
Pool::Key*, const Pool::Key*))'
BinaryHeap.h:19: error: candidates are: BinaryHeap::BinaryHeap(const BinaryHeap&)
BinaryHeap.h:34: error: BinaryHeap::BinaryHeap(int, int
(*)(K, K)) [with K = Pool::Key*, D = GSTask*] <near match>
I've make sure that every thing is matched with the template. What
am I missing?
What I don't understand is, why g++ assumed that I pass an int& to
BinaryHeap ctor, while I clearly used an int (the size variable)?
And also, I defined compareTo as a typedef to int(*)(const K, const K),
but g++ reported (*)(K, K) instead (at line BinaryHeap.h:34) ?
--
-- Verdi March --