Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started