Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134521176
Author: SAVITCH
Publisher: PEARSON
Question
Book Icon
Chapter 16, Problem 5PP
Program Plan Intro

  • Include required library files.
  • Define a class named “StackOverflowException”.
    • Inside the access specifier “public”,
      • Define a constructor to assign the message
      • Declare a parameterized constructor to assign “msg” to message.
      • Define a function “display” to return message.
    • Inside the access specifier “private”.
      • Declare a string variable “message”.
  • Define a class named “StackEmptyException”.
    • Inside the access specifier “public”,
      • Define a constructor to assign the message
      • Declare a parameterized constructor to assign “msg” to message.
      • Define a function “display” to return message.
    • Inside the access specifier “private”.
      • Declare a string variable “message”.
  • Define a class named “Stack”.
    • Declare an integer array and variable.
    • Inside the access specifier “public”,
      • Define a constructor to assign “-1” to “top”.
      • Define a “push()” function.
        • “try” block to check the top is equal to “3”.
          • The condition is true, throw exception.
          • Otherwise increment the top and the value is assigned to stack.
        • “catch” block to display the error message.
      •  Define a “pop()” function.
        • “try” block to check the top is equal to “-1”.
          • The condition is true, throw exception.
        • Otherwise decrement the top and return the value.
        • “catch” block to display the error message.
  • Define a “main()” function.
    • Create an object for class “Stack”.
    • Then check the “push()” and “pop()” function.

Blurred answer
Students have asked these similar questions
hi, I need help to resolve the case, thank you
The following table shows the timestamp and actions by two users. Choose the best option that describes the outcome of the actions. Time JohnSara 10:14 select* from hr.employees; 10:15 Update hr.employees set salary= 100  where employee_id= 206; 10:16 Commit:  Select* from hr.employees; 10:18 Commit: 10:20 Select* from hr.employees;  Commit:   John's query willreturn the same results all three times it is executed as they are run in the same session.   John's queries run at10:16 and10:20 produce the same result, which is different from the one at 10:14   John's query run at 10:16 waits until 10:18 to produce results, waiting for the commit to happen.   John's queries run at 10:14 and 10:16 produce the same result, which is different from the one at 10:20
what's the process used to obtain IP configuration using DHCP in Windows Server.
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
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning