Answered step by step
Verified Expert Solution
Link Copied!

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:
1. Use ONLY the templated DStack.h and LStack.h uploded into this directory.
2. Keep the same names (reverse, catStack and length) for the respective additional member and nonmember functions.
3. Do not change any of the given identifiers of templated DStack.h and LStack.h.
4. 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.
5. 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 1 and Problem 2.
6. 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 (two.h 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 20-25 lines.
Problem 1: max total 40 points
a) Design (write the prototype 5 points) and implement (write the definition 15 points) of a
new templated member function reverse for the templated class DStack.h on dynamic array.
(max 20 points)
// DStack.h
template
class Stack
{ public:
Stack(int numElements =128);
~Stack();
Stack(const Stack & original);
Stack& operator=(const Stack & original) ;
void makeEmpty();
bool full() const ;
void push(const ItemType & value);
ItemType top() ;
void pop();
void pop(ItemType& 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 stack1;
Stack stack2;
The statement
stack1.reverse(stack2);
copies the elements of stack1 onto stack2 in reverse order. That is, the top element of stack1 is the bottom element
of stack2, and so on. The old content of stack2 is destroyed and stack1 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 20-25 lines.
max 10 points for main(); max 10 points for the output
Submission of Problem 1a & 1b:
One .h file, one .cpp file and one screenshot (image)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications Dexa 2023 Workshops 34th International Conference Dexa 2023 Penang Malaysia August 28 30 2023 Proceedings

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Atif Mashkoor ,Johannes Sametinger ,Maqbool Khan

1st Edition

ISBN: 303139688X, 978-3031396885

Students also viewed these Databases questions