how to model and implement a queue dynamically, computer science homework help
how to model and implement a queue dynamically, computer science homework help
Lab 9
We have seen in class how to model and implement a queue dynamically using a Linked List in a composition relation.
Implement the class Queue that uses Linked List as an inheritance relation.
Note: You have as attachment the code of the Linked List and Queue using Linked List as composition. You just need to modify it.
#ifndef QUEUE_H
#define QUEUE_H_x000D_
#include "LinkedList.h"_x000D_
#include <stdexcept>_x000D_
using namespace std;_x000D_
_x000D_
template<typename T>_x000D_
class Queue_x000D_
{_x000D_
public:_x000D_
Queue();_x000D_
void enqueue(T element);_x000D_
T dequeue() throw (runtime_error);_x000D_
int getSize();_x000D_
_x000D_
private:_x000D_
LinkedList<T> list;_x000D_
};_x000D_
_x000D_
template<typename T>_x000D_
Queue<T>::Queue()_x000D_
{_x000D_
}_x000D_
_x000D_
template<typename T>_x000D_
void Queue<T>::enqueue(T element)_x000D_
{_x000D_
list.addLast(element);_x000D_
}_x000D_
_x000D_
template<typename T>_x000D_
T Queue<T>::dequeue() throw (runtime_error)_x000D_
{_x000D_
return list.removeFirst();_x000D_
}_x000D_
_x000D_
template<typename T>_x000D_
int Queue<T>::getSize()_x000D_
{_x000D_
return list.getSize();_x000D_
}_x000D_
_x000D_
#endif"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.
Discount Code: CIPD30
Click ORDER NOW..


