1 Replies - 475 Views - Last Post: 23 October 2009 - 03:39 PM Rate Topic: -----

#1 enigma-paradox  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 16-June 08

I keep getting this error in my function template

Posted 23 October 2009 - 03:35 PM

I've gotten rid of most of the error that I had with a function template that I am writting for class. However there is one error that I keep getting and I cannot figure out why.

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.

Is This A Good Question/Topic? 0
  • +

Replies To: I keep getting this error in my function template

#2 KYA  Icon User is offline

  • su wtf -am -i /doing/with/my/life
  • member icon

Reputation: 2979
  • View blog
  • Posts: 19,033
  • Joined: 14-September 07

Re: I keep getting this error in my function template

Posted 23 October 2009 - 03:39 PM

Priority_Queue<int> PQ = Priority_Queue();

//should be

Priority_Queue<int> PQ = Priority_Queue<int>();


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1