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 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

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_2

Step: 3

blur-text-image_3

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 2022 Workshops 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 In Computer And Information Science 33

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Alfred Taudes ,Atif Mashkoor ,Johannes Sametinger ,Jorge Martinez-Gil ,Florian Sobieczky ,Lukas Fischer ,Rudolf Ramler ,Maqbool Khan ,Gerald Czech

1st Edition

3031143426, 978-3031143427

More Books

Students also viewed these Databases questions