Implementation of the stack class in c++, C/C++ Programming

Implementation of the Stack class in C++:

How to implement stack class in c++.

int Stack::push(int elem)

{

   if (top < nmax)

   {

      list[top++] = elem;

      return 0;

   }

   else

      return -1;

}

 

int Stack::pop(int& elem)

{

   if (top > 0)

   {

      elem = list[--top];

      return 0;

   }

   else

      return -1;

}

 

void Stack::print()

{

   for (int i = top-1; i >= 0; --i)

      cout << list[i] << "\n";

}

Posted Date: 10/19/2012 3:06:48 AM | Location : United States







Related Discussions:- Implementation of the stack class in c++, Assignment Help, Ask Question on Implementation of the stack class in c++, Get Answer, Expert's Help, Implementation of the stack class in c++ Discussions

Write discussion on Implementation of the stack class in c++
Your posts are moderated
Related Questions
A string S is said to be "Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets (''a''-''z'') and the asci

write a c++ program for pebble merchant

P o i n t e r d e c l a r a t i o n f o r me m b e r f un c t i o n : M e t h o d 1 : W h e n C l a ss i s n o t

one of the segments is showing compilation error...

Rule: To determine the canonical form we should OR the min terms. A min term is defined as a Boolean equation of the input if the output is logic '1'. If the input is logic '1'

is getchar() is a C++ library function?

Write a C++ program that calculates the area of a circle, rectangle and square using overloaded versions of a function area ().Your program should include both declarations and def

Project Description: I need to convert AFL code of Amibroker to DLL plugin to hide original formula, and also to protect the DLL and making it hardware locked. I need to wrap th

Given an integer n and a permutation of numbers 1, 2 ... , n-1, n write a program to print the permutation that lexicographically precedes the given input permutation. If the given

Hey vrcoder I have got similar way but the game builder has sent me the game unfinished and left. I saw it on a link on line but they have wiped the old message with the link in it