Thanks. I checked the compiler output and it seems that the template Headers are not being matched up with the implementation code in the CPP file. I did some reading and it seems that I can't split template header and implementation code between two files. So, I merged to the two into the CPP file.

I'm still getting the linking error. The code is below. Should I have merged them into the Header file?

When I use this template heap, I'm storing pointer information so, the code for that is the following.

//How I use the template

@

BinaryHeap<GraphNode*> m_bhOpen;

BinaryHeap<GraphNode*> m_bhClosed;

BinaryHeap<GraphNode*> m_bhPath;

@

//The template implementation

@

#include <QtDebug>

#include <QVector>

template<typename T>

class BinaryHeap

{

private:

int m_iHeapSize;

QVector<T> m_vHeap;

public:

BinaryHeap();

BinaryHeap(int heapsize);

~BinaryHeap();

```
void SetSize(int heapsize);
void Pop();
void Push(T nodeIndex);
T Peek();
int Size();
```

};

//Ctor

template<typename T>

BinaryHeap<T>::BinaryHeap()

{

}

//Ctor

template<typename T>

BinaryHeap<T>::BinaryHeap(int heapsize)

{

m_iHeapSize = heapsize;

m_vHeap.reserve(heapsize);

}

//Dtor

template<typename T>

BinaryHeap<T>::~BinaryHeap()

{

}

template<typename T>

void BinaryHeap<T>::SetSize(int heapsize)

{

m_vHeap.reserve(heapsize);

}

//Pops a node off the heap

template<typename T>

void BinaryHeap<T>::Pop()

{

int index = 0;

```
m_vHeap[index] = m_vHeap[(int)m_vHeap.size() - 1];
m_vHeap.pop_back();
int temp = m_vHeap[index];
int currentIndex = 0;
int leftIndex = 0;
int rightIndex = 0;
while( index < (int)m_vHeap.size() / 2 )
{
leftIndex = 2 * index + 1;
rightIndex = leftIndex + 1;
if(rightIndex < (int)m_vHeap.size() && m_vHeap[leftIndex] < m_vHeap[rightIndex])
currentIndex = rightIndex;
else
currentIndex = leftIndex;
if( temp >= m_vHeap[currentIndex] )
break;
m_vHeap[index] = m_vHeap[currentIndex];
index = currentIndex;
}
```

}

//Pushes an element onto the heap

template<typename T>

void BinaryHeap<T>::Push(T nodeIndex)

{

//Add the new index to the heap

m_vHeap.push_back(nodeIndex);

```
//Retrieve the index of the newly added value and it's parent index
int index = (int)m_vHeap.size() - 1;
int temp = m_vHeap[index];
int parentIndex = (index - 1) / 2;
//Restack the heap as children cannot be larger than their parents
while( index > 0 && temp >=m_vHeap[parentIndex] )
{
m_vHeap[index] = m_vHeap[parentIndex];
index = parentIndex;
parentIndex = (parentIndex - 1) / 2;
}
```

}

//Peeks at the top most node

template<typename T>

T BinaryHeap<T>::Peek()

{

return m_vHeap[0];

}

//Returns the size of the heap

template<typename T>

int BinaryHeap<T>::Size()

{

return (int)m_vHeap.size();

}

@