Question: [36 points] Define a class called CharStack that implements a stack of character (char) values. The stack data structure is described in sections 2.11 and
![[36 points] Define a class called CharStack that implements a stack](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f2e4c948d2a_31266f2e4c8b5617.jpg)
[36 points] Define a class called CharStack that implements a stack of character (char) values. The stack data structure is described in sections 2.11 and 2.12 of the zyBook. It is a last-in, first-out (LIFO) collection of items. Below is a partial definition of the class, with only the public member functions. You must add private variables (and possible functions) and implement the public functions. class Charstack i private: // this is your job... public: Chartack // constructor: create an empty stack CharStack I destructor void push (char c) push character c onto the stack bool pop (char& out); // pop character from stack if non-empty pop charaste poppedkpty // return true if popped, false if empty bool peek (char&out): 1/ copy but do not remove top of stack; // return false if empty, true if non-empty bool empty/1 return true if empty, false if not empty int lenqth // return number of characters on the stack
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
