Please help me in this C++ program make sure it can run Create a class/struct. M
ID: 3794346 • Letter: P
Question
Please help me in this C++ program
make sure it can run
Create a class/struct.
Members:
MaxSize const = 10
Define an array that holds 10 items.
Count - indicates how many items are on the stack.
Methods:
Push
- Accepts a number and adds to the top of the stack.
- If the stack is full emit an error indicating full.
Pop
- Returns a number from the top of the stack.
- If the stack is empty, emit an error indicating the stack is empty.
IsEmpty
- Returns a boolean indicating if the stack is empty.
Explanation / Answer
#include #include #include using namespace std; struct stack { private: enum { MAX_SIZE = 10 }; int array[MAX_SIZE] ; // int count; //= 0; public: int stk[10]; int top; int count;// = 0; //public: bool full() const { return count == MAX_SIZE ; } /* bool empty() const { return count == 0 ; }*/ stack() { top = -1; } bool push(int element) { cout > element; if( full() ) { cerrRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.