Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Requirements: 1 . Use ONLY the templated DStack.h and LStack.h uploded into this directory. 2 . Keep the same names ( reverse , catStack and
Requirements:
Use ONLY the templated DStack.h and LStack.h uploded into this directory.
Keep the same names reverse catStack and length for the respective additional member and nonmember functions.
Do not change any of the given identifiers of templated DStack.h and LStack.h
For definitions of member functions use only private data members; empty and full are only two public member functions which can be used for member function definitions.
The full submission requires in total two.h files, two cpp files and two outputs images which additionally include the new member function prototypes and definitions, the prototype and definition of the new nonmember function and two screenshots as specified in the submissions of Problem and Problem
No friend functions.
What to submit
manual writing of files below will not be accepted as well as files copied and pasted into a doc or pdf document ; output should be taken as a snapshot.
Output can be submitted as an image or image pasted in doc. file
The h file twoh files are expected
The test or driver cpp file two cpp driver files are expected
Two outputs of the test drivers. The outputs images should have not less than lines.
Problem : max total points
a Design write the prototype points and implement write the definition points of a
new templated member function reverse for the templated class DStack.h on dynamic array.
max points
DStack.h
template
class Stack
public:
Stackint numElements ;
~Stack;
Stackconst Stack & original;
Stack& operatorconst Stack & original ;
void makeEmpty;
bool full const ;
void pushconst ItemType & value;
ItemType top ;
void pop;
void popItemType& item ;
add prototype of new member function reverse
void print const ;
private:
myTop;
int myCapacity,
ItemType myArrayPtr;
;
Function reverse copies the elements of a stack in reverse order onto another stack.
Consider the following statements.
Stack stack;
Stack stack;
The statement
stackreversestack;
copies the elements of stack onto stack in reverse order. That is the top element of stack is the bottom element
of stack and so on The old content of stack is destroyed and stack is unchanged.
b Write a driver program which uses objects storing different type of elements, all member
functions of the modified templated class Stack on dynamic time array and submit the output
screenshot submitted as an image having between lines.
max points for main; max points for the output
Submission of Problem a & b:
One h file, one cpp file and one screenshot image
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