Question: Question4 (35 Marks) Write a class for a simple stack (stack will be limited with maximum 1000 locations and will keep integers) (a) Number of

 Question4 (35 Marks) Write a class for a simple stack (stack

Question4 (35 Marks) Write a class for a simple stack (stack will be limited with maximum 1000 locations and will keep integers) (a) Number of locations will be kept in private section. (b) Array for stack and stack pointer will be kept in protected section. (c) In public section there will be three functions and a constructor. (i) Constructor will be used to initialize all member data and also it will be possible to determine length of stack just by sending a parameter to constructor (if NO parameter is sent to constructor for length of stack 10 will be set as default). (ii) "Set" function will be used to push an item into stack; if all locations are occupied, function will print "Stack is full" message on screen. (iii) "Get" function will just pop and return current item from stack; if all locations are empty, function will print "Stack is empty" message on screen. (iv) Finally, there'll be a function called "Show", (1) if no parameter is send, it will just return length of stack, (2) if a location is send it will return value at that location. If the location which is send as parameter is out of stack it will return 1. (1) Stacks use "FILO" or "LIFO" principle. (2) There is no need for "main O" function, write "Class" ONLY. (3) Any solution which is NOT asked will cost in mark deduction. (4) Assume that, all values that will be inserted into stack, will be positive integers

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!