Thank you for taking the time to help me.
This is a portion of a DHeap program to run a number of process based on priority level given to each process.
the following are some errors which I'm getting when trying to compile this code(this is a portion of the total code).
I think the errors are related to my definition of template.
dheap.h:3: error: ISO C++ forbids declaration of âDheapâ with no type
dheap.h:3: error: explicit instantiation of nontemplate âint Dheapâ
dheap.h:3: error: expected `;' before â<â token
dheap.h:35: error: expected constructor, destructor, or type conversion before â<â token
dheap.h:49: error: expected constructor, destructor, or type conversion before â<â token
dheap.h:59: error: expected initializer before â<â token
dheap.h:69: error: expected initializer before â<â token
dheap.h:80: error: expected initializer before â<â token
dheap.h:92: error: expected initializer before â<â token

//#include <iostream>
#define MAX_SIZE 500 // Maximun size of the heap.
template Dheap <class Process>
{
public:
Dheap ( int _d = 2 ); //I have included the d value of the heap.
~Dheap (void);
void insert (const Process&); // To insert an element in the heap.
void deleteMin (void); // To remove an element in the heap and return it.
bool IsEmpty(void)const; // Return true if the heap is empty;otherwise false.
void ToEmpty (); // To make the heap empty.
const Process& min (void)const; // To return the smallest key element in the heap.
bool IsFull(void)const; // To return true if the heap is full;otherwise false.
int size()const;
private:
// int SizeOfHeap; // (capacity) of the heap.
Process *arrptr; // The actual array pointer of the heap.
int Dvalue;
int back;
//void percolateDown (int );
};
#include<iostream>
using namespace std;
//#include "dheap.h"
// Input: None.
// Output: None.
// Return: None.
// Notes:A memory allocation.
template <class Process>
Dheap<Porcess>::Dheap(int _d)
//Dheap::Dheap ( int _d )
{
Dvalue = _d;
arrptr = new Process [MAX_SIZE]; // allocating for the new data.
back = 0; // position to insert a new element.
}
// Input: None.
// Output: None.
// Return: None.
// Notes: Deletion when allocation.
template <class Process>
Dheap<Process>::~Dheap (void)
{
delete []arrptr;
}
// Input: None.
// Output: None.
// Return: Bool.
// Notes: To only return true if the heap is empty; otherwise it will be false.
template <class Process>
bool Dheap<Process>::IsEmpty(void) const
{
return (back <= 1); // No elements in the heap therefore its empty.
}
// Input: None.
// Output: None.
// Return: bool.
// Notes: This function is to check and return true if the heap is full; otherwise,false.
template <class Process>
bool Dheap<Process>::IsFull(void)const
{
return (back == 0);
}
// Input: None.
// Output: None.
// Return: bool.
// Notes: This function is to check and return true if the heap is full; otherwise,false.
template <class Process>
bool Dheap<Process>::IsFull(void)const
{
return (back == MAX_SIZE);
}
// Input: Const integer reference named anumber.
// Output: None.
// Return: None.
// Notes: To insert an element named anumber with changing needed until the heaporder property is satisfy.
template <class Process>
void Dheap<Process>::insert( const Process & anumber )
{
if (IsFull())
{
cerr << "You can't add more" << endl;
}
arrptr [back ] = anumber; // To put the value in the heap.
// The indecies of curr and parent
int curr = element; // Because we want to have the current to be in position back
++back; // and then add it on next time.
// int par = curr / Dvalue; // The parent.
// while ( arrptr [ curr ] < arrptr [ par ] )
// {
// swap ( arrptr [ curr ] , arrptr [ par ] ); // The swaping occures in here
// Updating current and parent.
// curr = par;
// par = curr / Dvalue;
// }
while ((curr >0) && (arrptr[curr]< arrptr[curr1/Dvalue]))
{
int temp = arrptr[(cyrr1)/Dvalue];
arrptr[(curr1/Dvalue)] = arrptr[curr];
arrptr[curr] = temp;
curr = (curr 1 )/Dvalue;
}
}
// Input: None.
// Output: None.
// Return: Const integer of a reference type.
// Notes:The function is just to return the minmum item in heap,obviously will be found at root.
template <class Process>
const Process & Dheap<Process>::min(void) const
{
if(IsEmpty())
{
cerr << "Heap's Error, No Elements Therefore, "
<< "We Can Not Return Any Value!!" << endl;
exit(1);
}
return arrptr[0]; // return the smallest item, that is, in the root.
}
// Input: None.
// Output: None.
// Return: None.
// Notes:To remove the minimum item and place it in the element named minnum.
template <class Process>
void Dheap<Process>::deleteMin( void )
{
if (IsEmpty())
{
cerr << "Heap's Error< No Elements Therefore, "
<< "WE Can Not Delete The Minimum Element!!" << endl;
exit(1);
}
// the array is 1 indexed, so the root is at [1]
// back;
// int temp = heap
arrptr[1] = arrptr[back1]; // The Removing at the root.
back; // remove the last element
//do the percolating down until the heaporder property is satisfty.
int curr = 1; // start at the root
int left = 2; // curr * Dvalue
while ( left < back )
{
// find the smallest valid child
int small = left;
for (int i = 0; i < Dvalue; i++) // For the children of the parent
{
if ( ( left + i ) < back &&
( arrptr[ left + i ] < arrptr[ small ] ) )
small = i; // keep where that child
}
// we have the smallest valid child, see if we need to swap
if ( arrptr [ small ] < arrptr [ curr ] )
{
swap( arrptr [ small ] , arrptr [ curr ] );
// Updating.
curr = small;
left = curr * Dvalue;
}
else
left = back;// we are done
}