Problem with "no matching function for call"
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<typename K, typename D> //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<Key*, GSTask*> 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<Pool::Key*, GSTask*>::BinaryHeap(int&, int (*)(const Pool::Key*, const Pool::Key*))' BinaryHeap.h:19: error: candidates are: BinaryHeap<Pool::Key*, GSTask*>::BinaryHeap(const BinaryHeap<Pool::Key*, GSTask*>&) BinaryHeap.h:34: error: BinaryHeap<K, D>::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 --
On Sunday 20 July 2003 00:24, Cincai Patron wrote:
/******************* Pool.cpp ***********************/ Pool::Pool(int size) { e_pool = new tpool(size, &RRTPool::compareKey); //<---- error here }
Sorry, should've been: e_pool = new tpool(size, &Pool::compareKey); -- -- Verdi March --
participants (1)
-
Cincai Patron