Question: 2. (13 points) Consider the partial specification for Stack class shown below which also appears on the course web site and which we discussed in

2. (13 points) Consider the partial specification for Stack class shown below which also appears on the course web site and which we discussed in class. #include using namespace std; class Stack { public: Stack(int size = 1); // make a new stack ~Stack(); // finalize the stack Stack& operator=(const Stack &s); // assign one stack to another void push(char c); // push c onto the stack char pop(); // pop top char off the stack bool isEmpty() const; // ask if the stack is empty bool isFull() const; // ask if the stack is full void resize(int size); // resize the stack to size chars friend ostream& operator<<( ostream& out, const Stack &s); // print the stack private: char *storage; // place where chars are stored int num; // number of chars stored in the stack int size; // max num of chars that could be stored }; a. (2 pts) What is the effect of the const keyword when it appears after the function name as in the specification for isEmpty()?

b. (2 pts) Why is there a destructor for this class?

c. (2 pts) Implement the destructor.

d. (2 pts) What important big three function is missing from this specification? What are the implications of its absence? NOTE: there are two questions which must be answered here.

e. (5 pts) Implement the assignment operator so it implements a deep copy of a Stack. If you think it helpful, you may assume the existence of the missing big-three function for your implementation.

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!