Question: c++ 7. Write the declaration of a class named AStack for implementing a Stack data structure for storing integer elements. The implementation will use a

7. Write the declaration of a class named AStack for implementing a Stack data structure for storing integer elements. The implementation will use a dynamic array for organizing and storing the stack elements. The AStack members are described as follows: Data members: only private access. - maxsize - an integer variable defining the size of the stack, i.e. the maximum number of elements that can be stored in the AStack object. - Stptr - a pointer variable of type int. The pointer stores the address of the dynamic array used for creating an AStack object. - top - an integer variable referring to the position of top-most element in the stack, i.e. the position of the last used cell in the StPtr array in the AStack object. Member functions: under public access: - AStack - the parameterized constructor for creating an empty AStack object. The function takes an int parameter corresponding to the size of the stack with default value as 5 . The constructor creates a dynamic array of the int, and assigns its address to the StPtr variable. The constructor also initializes the variable top =1. - isEmpty - the function to check if the stack is empty or not, i.e. has no elements on the stack. The function returns true if all the cells in StPtr array in the AStack object are unused else returns false. - ispull - the function to check if the stack has full, i.e. has no free space for new elements. The function returns true if all the cells in the StPtr array in the AStack object have been used else returns false. - push - The function performs the push operation on the stack for an int value given by the user. If the stack has free space, the function stores the given value in the next free cell in the StPtr array in the AStack object. Else the function prints a message stating "Stack Ful1". The function does not return anything. - pop - The function performs the pop (return and remove) operation on the stack when called by the user. If the stack is not empty, the function returns the value from the last used cell in the StPtr array in AStack object. Else the function returns a value equal to 111, and also prints the error message stating "stack Empty". 8. Complete the definition of parameterized constructor for AStack class as described in question 7. 9. Complete the definition of isEmpty member function as described in question 7. 10. Complete the definition of push member function as described in question 7
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
