Thread: Compiler Error
View Single Post
Old 06-10-2004, 06:09 PM   #3 (permalink)
saiz66
Registered User
 
Join Date: May 2004
Posts: 11
saiz66 is on a distinguished road
Sorry I will just paste my program.
Code:
#include "pqueuebh.cpp"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

class Patient
{
	
private:
	int itsPatientNumber;
	int itsPriority;
	int itsTime;
	int itsMisdiagnose;
	
public:

	Patient();
	~Patient();
	void setPriority(int priority);
	int getPriority();
	void setTime(int time);
	int getTime();
	void setMisdiagnose(int misdiagnose);
	int getMisdiagnose();
	
	bool operator < (const Patient &P)
	{
		if (itsPriority < P.itsPriority)
			return true;
		else if (itsPriority > P.itsPriority)
			return false;
		else if (itsTime < P.itsTime)
			return false;
		else 
			return true;
	}

};

Patient::Patient()
{
	itsPriority = itsTime = itsMisdiagnose = 0;
}


Patient::~Patient()
{
}

void Patient::setPriority(int priority)
{
	itsPriority = priority;
}

int Patient::getPriority()
{
	return itsPriority;
}

void Patient::setTime(int time)
{
	itsTime = time;
}

int Patient::getTime()
{
	return itsTime;
}

void Patient::setMisdiagnose(int misdiagnose)
{
	itsMisdiagnose = misdiagnose;
}

int Patient::getMisdiagnose()
{
	return itsMisdiagnose;
}

int main()
{
	
	using namespace std;
	using std::cout;
	using std::cin;
	
	PQueue <Patient> PQ;
	
	PQ.Insert(P1);

	return 0;
}
This is my code. And I implemented the priority queue which my prof gave me.

This is the header file which basically states what I need to pass and what it returns.

Code:
  #ifndef PQUEUEBH_HPP
   #define PQUEUEBH_HPP

   // Priority Queue: Header File

   template <class Etype>

   // Assumption: Etype is defined on the operation <

   class PQueue
   {
      public:

         // Constructor
         //
         // Input  : None
         // Purpose: To create an empty Priority Queue
         // Output : None

            PQueue ( );


         // Copy constructor
         //
         // Input  : Priority Queue PQ
         // Purpose: To initialize Priority Queue to PQ
         // Output : None

            PQueue ( const PQueue & PQ );


         // Destructor
         //
         // Input  : None
         // Purpose: To free memory of Priority Queue
         // Output : None

            ~PQueue ( );


         // Copy assignment
         //
         // Input  : Priority Queue PQ
         // Purpose: To assign PQ to current Priority Queue
         // Output : Current Priority Queue

            const PQueue & operator= ( const PQueue & PQ );


         // Insert
         //
         // Input  : Element E and integer i (optional)
         // Purpose: To place E into the Priority Queue and
         //          To maintain prioritization when i=1 or omitted
         // Note   : Prioritization may NOT be maintained when i!=1
         // Output : 1 if successful; 0 otherwise

            int Insert ( const Etype & E, int i=1 );


         // DeleteMin
         //
         // Input  : None
         // Purpose: To return the highest priority element E and
         //          To delete E from the Priority Queue
         // Output : Element E and 1 if successful; 0 otherwise

            int DeleteMin ( Etype & E );


         // Length
         //
         // Input  : None
         // Purpose: To the return the current size of the Priority Queue
         // Output : Current size of Priority Queue

            int Length ( ) const;


         // Empty
         //
         // Input  : None
         // Purpose: To check if Priority Queue is empty
         // Output : 1 if empty; 0 otherwise

            int Empty ( ) const;


         // Clear
         //
         // Input  : None
         // Purpose: To re-initialize Priority Queue to empty
         // Output : None

            void Clear ( );


      private:

         // DoubleArray
         //
         // Input  : None
         // Purpose: To double the maximum size of Priority Queue
         // Output : None

            void DoubleArray ( );


         // FixHeap
         //
         // Input  : None
         // Purpose: To restore the heap-order property
         //          of the binary heap
         // Output : None

            void FixHeap ( );


         // PercolateDown
         //
         // Input  : Position i
         // Purpose: To restore the heap-order property
         //          of the binary heap rooted at position i
         // Output : None

            void PercolateDown ( int i );


         // PercolateUp
         //
         // Input  : Position i
         // Purpose: To restore the heap-order property
         //          of the binary heap along the path from i to the root
         // Output : None

            void PercolateUp ( int i );


         // Data Members


            // Current and maximum size of Priority Queue
            int CurrentSize, MaxSize;

            // 1 if heap-order property is preserved; 0 otherwise
            int OrderOK;

            // Dynamic binary heap to store the elements of Priority Queue
            Etype *Array;

   };

   #endif
I was taught that I didn't need to touch the implementation file. Could you tell me what I am doing wrong?
saiz66 is offline   Reply With Quote