I found this site(http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=298), that seems like it is talking about my problem, but I still don't see where my mistake is.
here is my header file
#define MAX 100
#include <iostream>
#include <algorithm>
using namespace std;
template <typename T>
class Priority_Queue
{
public:
Priority_Queue();
void push(T item);
T top();
void pop();
bool empty();
private:
T myArray[MAX];
int mySize;
};
template <typename T>
Priority_Queue<T>::Priority_Queue()
{
myArray[0]=0;
mySize = 0;
make_heap(&myArray[0], &myArray[mySize]);
}
template <typename T>
void Priority_Queue<T>::push(T item)
{
myArray[mySize] = item;
push_heap(&myArray[0], &myArray[mySize]);
mySize += 1;
}
template <typename T>
void Priority_Queue<T>::pop()
{
for(int i=0;i<mySize;i++)
{
myArray[i]= myArray[i+1];
}
make_heap(&myArray[0], &myArray[mySize]);
}
template <typename T>
T Priority_Queue<T>::top()
{
return myArray[0];
}
template <typename T>
bool Priority_Queue<T>::empty()
{
if(mySize == 0)
{
return True;
}
else
{
return False;
}
}
and here is the file that I'm using to test the header, this part isn't finished b/c I keep on getting the same error that I can't figure out.
#include <iostream>
#include "Priority_Queue.h"
using namespace std;
int main()
{
int stopper;
Priority_Queue<int> PQ = Priority_Queue();
PQ.push(100);
PQ.push(1);
PQ.push(10);
cin>>stopper;
return 0;
}
i have not sure what this error means even after googleing it
cuments\visual studio 2005\projects\priorityqueue\priorityqueue\pq_tester.cpp(10) : error C2955: 'Priority_Queue' : use of class template requires template argument list
I'd really appreciate any help.

New Topic/Question
Reply




MultiQuote




|