lab work computer scinec

Anonymous
timer Asked: Nov 16th, 2016

Question description

Lab work

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.

use this:

#ifndef QUEUE_H
#define QUEUE_H
#include "LinkedList.h"
#include <stdexcept>
using namespace std;

template<typename T>
class Queue
{
public:
Queue();
void enqueue(T element);
T dequeue() throw (runtime_error);
int getSize();

private:
LinkedList<T> list;
};

template<typename T>
Queue<T>::Queue()
{
}

template<typename T>
void Queue<T>::enqueue(T element)
{
list.addLast(element);
}

template<typename T>
T Queue<T>::dequeue() throw (runtime_error)
{
return list.removeFirst();
}

template<typename T>
int Queue<T>::getSize()
{
return list.getSize();
}

#endif

Studypool has helped 1,244,100 students
flag Report DMCA
Similar Questions
Hot Questions
Related Tags
Study Guides

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors