Question: 1. Use the class stack discussed in the lectures to make a stack class template. Write the methods of the template class in the following

 1. Use the class stack discussed in the lectures to makea stack class template. Write the methods of the template class in

1. Use the class stack discussed in the lectures to make a stack class template. Write the methods of the template class in the following program which uses the string class as the template parameter For marking purposes, run program and push bob, joe and jean onto the stack. Print the stack to the output file then pop twice and print again // File: stacktemplate.cpp // This program implements a stack template class #include #include #include using namespace std; template data; vector holding the stack items // maximum size of the stack // num ber of items on the stack public: stack(int sz); // constructor, max sz void push (const T kitem); // push a copy of item onto the stack // pop an item off the stack pop (void); void write (ostream kout) const; // send the data stored to out bool empty(void) const; bool full (void) const; // check for empty stack // check for full stack int main(void) stack mystack (5); ofstream fout ("stackout.txt") char ch; string x; while(1) // print a little menu np push n"; cout

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!