Thank you for taking the time to help me.
This is a portion of a D-Heap 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 non-template â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 heap-order 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[curr-1/Dvalue]))
          {
              int temp = arrptr[(cyrr-1)/Dvalue];
              arrptr[(curr-1/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[back-1]; // The Removing at the root.
    --back; // remove the last element

    //do the percolating down until the heap-order 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
    }

aomran,
Welcome to daniweb.

Please "Edit" your post. Use [code] tag to post source code.

commented: I really hate it when people don't use code tags, for two main reasons: it makes their code 'unreadable', and emotes begin two show up everywhere in their code which lets you figure it all out :P +22
commented: I cannot reply to your PM. PM seems to be blocked for your account. +8

Thanks for replying, I have tried to tag my code as recommended , I select all but could not find # on edit. is there other way to do it.

aomran

Ok despite the code tags that you can (a) get from the advanced edit or simply just type them.

Templates:

Ok you need to remember the syntax of a class has not really changed.

e.g.

// Non-template class
class A
{
    void method();
};

void A::method() { return; }

// Template class [Template is added on top]
template<typename Item>
class B
{
    void method();
    void methodB() { return; } 
};

template<typename Item>
void B<Item>::method() { return; }

Note who you add the template part above each method and
as a tag to the class name. That tells the compiler that it is a general instance of B.

The remainder of your errors are basic typos and such. (I haven't run your code so you will have runtime errors I guess.)

just read few articles about template, but still could not figure out what those three error on the same line means. any hint?

dheap.h:3: error: ISO C++ forbids declaration of âDheapâ with no type
dheap.h:3: error: explicit instantiation of non-template âint Dheapâ
dheap.h:3: error: expected `;' before â<â token

Is my declaration of the template statement ok?

//#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);

NO, it should be :

tempate<typename Process>
Dheap { //code };
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.