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

[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

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!