DESCRIPTION
A C++ program to implement a generic stack class. Include a default constructor, destructor and member functions push( ) to put values into the stack, pop( ) to remove values from stack, isempty( ) and isfull( ) for testing whether stack is empty or full. Use array implementation of stack. Write a main program to test your class for integer and character type data.
PROGRAM
#include <iostream>
using namespace std;
template<class T>
class stack{
private:
T a[10];
int top;
public:
stack(){
top=-1;
}
int isfull(){
if(top==9)
return 1;
return 0;
}
A C++ program to implement a generic stack class. Include a default constructor, destructor and member functions push( ) to put values into the stack, pop( ) to remove values from stack, isempty( ) and isfull( ) for testing whether stack is empty or full. Use array implementation of stack. Write a main program to test your class for integer and character type data.
PROGRAM
#include <iostream>
using namespace std;
template<class T>
class stack{
private:
T a[10];
int top;
public:
stack(){
top=-1;
}
int isfull(){
if(top==9)
return 1;
return 0;
}