Showing posts with label POP. Show all posts
Showing posts with label POP. Show all posts

Tuesday, 12 May 2015

[CPP] STACK CLASS THAT CAN HANDLE INT AS WELL AS CHAR (& MORE) - GENERIC CLASS

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;
                }