Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
Question
Book Icon
Chapter 18.2, Problem 13STE
Program Plan Intro

Member functions in stack template adapter class:

The member functions in stack templates are given below:

  • “s.size()”:
    • This function is used to returns the number of elements in the stack.
    • “s” is object of stack template adapter class.
  • “s.empty()”:
    • This function is used to returns “true” if the stack is empty.
    • Otherwise, this function returns “false”.
  • “s.top()”:
    • This function is used to returns top value of the given stack.
  •  “s.push(Value)”:
    • This function is used to insert a “Value” to the top of stack.
  •  “s.pop()”:
    • This function is used to removes the top value of the stack.
    • In stack, the “pop” function is a void function.
      • So, it does not return the removed value.
  • “st1 == st2”:
    • This function is used to check whether the
      two stacks are equal or not.
    • If “st1.size == st2.size”, then returns “true”. That is if the number of elements in stack “st1” is equal to corresponding elements in stack “st2”.
    • Otherwise, returns “false”.

Blurred answer
Students have asked these similar questions
If the elements “A”, “B”, “C” and “D” are placed in a stack and are removed one at a time, in what order will they be removed?
Write a method to reverse the content of a stack. Inside the method, you may create exactly one temporary container -- either a stack or a queue.  It is alright to create variables of primitive data types (such as, an integer), if required. You must use the following header. public void reverse(Stack s){
What is the operation that adds items to a stack? Get Set Pop Push
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning