Question: 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 2: max total 60 points
a) Design (write the prototype 5 points) and implement (write the definition 15 points) a new
templated member function catStack for Stack based on Linked Nodes (LStack.h). Function
catStack creates a new stack by adding elements of one existing object of LStack class to another
existing object of the same class. Do not destroy both existing objects of LStack class.
(max 20 points)
// LStack.h
template
struct NodeType
{
ItemType info ;
NodeType *next;
} ;
template
class Stack
{
public:
Stack ();
~Stack ();
Stack( const Stack& original );
void operator=(Stack &s);
void makeEmpty();
bool full() const;
bool empty() const;
void push(const ItemType& item);
void pop(ItemType& item);
void pop();
ItemType top() const;
void print ) const;
private:
NodeType* topPtr;
};
b) Write a driver program which includes
- the prototype (5 points) and definition (15 points) of a new nonmember function length for
LStack.h which returns the actual number of stack elements;
max 20 points
- main() which creates objects storing different type of elements and uses all member
functions of the modified templated class Stack on linked nodes and the new nonmember
function. Submit the output (screenshot, submitted as an image) having between 20-25 lines.
max 10 points for driver program; max 10 points for the output
Submission of Problem 2a and 2b. One .h file, one .cpp file and one screenshot (image).

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!