My Project is to create a MaxHeap priority queue to sort voters. Everything compiles fine but the linker gives me a wierd error:
1>Main.obj : error LNK2019: unresolved external symbol "public: __thiscall MaxHeap<class Voter,class SalaryCompare>::MaxHeap<class Voter,class SalaryCompare>(class Voter * * const,int,int)" (??0?$MaxHeap@VVoter@@VSalaryCompare@@@@QAE@QAPAVVoter@@HH@Z) referenced in function _main
Anyone have any ideas?
The MaxHeap.h is:
#pragma once
template<class Elem, class Comp>
class MaxHeap {
public:
MaxHeap(Elem *[], int, int);
bool insert(Elem * element);
bool removeMax(Elem *&element);
bool remove(int pos, Elem *&element);
void buildHeap();
int heapsize();
bool isLeaf(int pos);
int leftChild(int pos);
int rightChild(int pos);
int parent(int pos);
private:
Elem **Heap;
int size;
int n;
void siftdown(int);
void swap(int, int);
};
and the Constructor I'm calling is:
template<class Elem, class Comp>
MaxHeap<Elem, Comp>::MaxHeap(Elem *h[], int num, int max) {
Heap = new Elem *[max];
n = num;
size = max;
for(int i = 0; i < num; i++)
Heap[i] = h[i];
buildHeap();
}
And finally the main function:
const int MAX_SIZE = 5000;
int main() {
Voter *voterArr[MAX_SIZE];
int numRec = makeList(voterArr);
MaxHeap<Voter, SalaryCompare> voters(voterArr, numRec, MAX_SIZE);
return 1;
}
note:I'm using Visual Studio 2008 Pro