Question: ( Object Oriented Programming C++ ) Q. Topic: Inheritance Create a Class Named Stack that has an integer array of size 5 and a variable
( Object Oriented Programming C++ )
Q. Topic: Inheritance
Create a Class Named Stack that has an integer array of size 5 and a variable top for location of data on stack. Make a function named push to place data in stack. Make a function named pop to get data from stack. Create another Class named Stack2 that is inherited from class Stack. o Make push and pop functions in this class Stack2. o Now push function before pushing the data on stack first checks if the stack is full. If the stack is not full then it calls the push function of its parent class. o Now pop function before popping out the data from stack first checks if the stack is empty. If the stack is not empty, then it calls the pop function of its parent class. Make an object of Stack2 class and test the push and pop functions in main() function.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
