I am Making a STACK class which could hold a Binary Tree Nodes.
I have defined a class Node.
Then made a linkedlist classs.
and finally the stack class. All are Template based.
But during compilation it is giving me the following error.
error: expected constructor, destructor, or type conversion before '<' to
I am using GCC via KDEVELOP on SUSE 11.0
Here is stack.h
#ifndef STACK_H
#define STACK_H
#include "linkedlist.h"
#include <iostream>
#include "stack.cpp"
using namespace std ;
template <class T>
class stack
{
public:
stack();
~stack();
void push(T c) ;
T pop() ;
bool is_empty() ;
T peek() ;
/*void display_stack() ;*/
private:
linkedlist<T> lst ;
};
#include "stack.cpp"
#endif
and here is its implementation.
template <class T> stack<T>::stack()
{
}
template <class T> stack<T>::~stack()
{
}
template <class T> void stack<T>::push(T c)
{
lst.Insert(c) ;
}
template <class T> T stack<T>::pop()
{
T c = lst.get_head_suffix() ;
lst.Remove() ;
return c ;
}
template <class T> bool stack<T>::is_empty()
{
if (lst.get_head() == 0)
return true ;
else
return false ;
}
template <class T> T stack<T>::peek()
{
if (!is_empty())
{
T c = lst.get_head_suffix() ;
return c ;
}
}
Any help would be warmly welcomed so plzzz... help me.
Thanks.