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

Assignment Help:

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

}


Related Discussions:- Implementation of the stack class in c++

Simple generic version of method isequalto, Write a simple generic version ...

Write a simple generic version of method isEqualTo that compares its two arguments with the equals method and returns true if they are equal and false otherwise. Use this generic m

Luminous jewel polishing neckiace, Byteland county is very famous for lumin...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Flowchart, questiCreate a flowchart that displays the student''''s average ...

questiCreate a flowchart that displays the student''''s average score for three quizzes. + Assume that there are 3 sections each having 5 students + The only valid number to be en

Array, Write a program to count the prime number in array

Write a program to count the prime number in array

Illustration of plot function, Illustration of Plot function: To be mo...

Illustration of Plot function: To be more common, the script could prompt the user for the time and temperature, instead of just assigning the values. Then, the axis function

Program is to perform all the functions of super bazaar, Program is to perf...

Program is to perform all the functions that are performed in a super bazaar: class stock   {   private:     int itno;     char itname[20];     char brname[20];

Standard input- output using motorola and intel devices, Talking to IO boar...

Talking to IO boards inside a computer or microcontroller depends upon the principles used by the microprocessor to address physical devices. On Motorola systems all devices connec

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd