Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

need whole program with c++ format Assignment: The Queue and the Class Template A class template allows a class to be defined around varlable types;

need whole program with c++ format

image text in transcribedimage text in transcribed

Assignment: The Queue and the Class Template A class template allows a class to be defined around "varlable types; these variable types will be specified in source code elsewhere so that the compiler can instantlate instances of the templates for the specific types desired. In this assignment, the original classes will be modified to work with types other than just integers. For example, one program may use these class templates to implement a queue of integers, while another program could implement a queue of double s or Customer s with the same class templates. From a pragmatic perspective, it is often easier to develop class templates by first writing the class with a fixed data type, then modifying it for generality once all debugging and testing for the well known type is completed. To illustrate this, you will be developing a Queue class for this assignment, based on the code you created in lab. But first, we will create a queue that works for the fixed type int. After you get that working, you will generalize it to a class template that can support (nearly) any type of payload. The Queue The queue data structure is a First-In, First-Out collection. Items are added to the queue (usually we call this action enqueue) and they line up just as you would in a line for an amusement park ride. Then, when itens are removed, the one that is at the front of the queue (i.e. the one that has been waiting the longest) is removed first. We call this action dequeue. Create a new headerimplementation file pair named "IntQueue.h and IntQueue.cpp. Use your work on the Intlist in lab and your experience in specializing it to a stack as a guide. The primary difference between the general-purpose ist and the queue is the way items are added and removed. The queue should only support one method of addition (enqueue)) and one method of removal (dequeu). These operations will map to adding at the end of the list and removing at the front, respectively. Since queue-like operations require you to add at the end of the list, you will need to add some functionality to your IntList implementation. Add a tail pointer to the IntList (as a private attribute that is initialized appropriately), and then create an add back) method in Intlist to allow items to be efficiently added at the end of the list. Don't forget to update your existing IntList methods to keep the tail1 pointer consistent with the state of the list! Once you have completed these changes, your list will now support all the operations necessary to operate as the underlying container for your queue. Your IntQueue class should implement the following interface: class IntQueue public: bool is empty consti void enqueue( int operand) int dequeue void debug write ostream& outfile) const; private: IntList list; ti ostream& operator

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

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions

Question

3. Describe the communicative power of group affiliations

Answered: 1 week ago