Question: CS 373 Home-Work project 10 Read the given .cpp file Can we declare an object of arrayListType? If yes, what member/non-member functions can this object

CS 373 Home-Work project 10

Read the given .cpp file

Can we declare an object of arrayListType? If yes, what member/non-member functions can this object be used with? If no, why not?

Can we declare an object of unorderedArrayListType? If yes, what member/non-member functions can this object be used with? If no, why not?

For the given main, identify which member/non-member functions of which class will be invoked. Include constructor (specify which constructor if there is more than one constructor in a class) and destructor in your answer.

You should be able to run the given .cpp if you comment out the declaration of the queue class.

Part 2

Create a queue class by priviate inherting the unorderedArrayListType class. A queue class is a First-In-First-Out data structure. To understand a queue, think of a checkout line at a grocery store: the person at the front is served first (removed), and people are added to the line from the back end.

class queue : private unorderedArrayListType

{

public:

bool isEmpty() const; // test whether queue is empty

// Post: returns true if queue is empty, otherwise returns false

int size() const; // return size

// Post: returns the number of elements in the queue

int front() const; // returns the element at the front of the queue. This should be the "oldest" element, the same element that will be removed if deque() is called next

// Pre: the queue is not empty

// Post: returns the element at the front of the queue

int back() const; // returns the element at the back of the queue. This should be the "youngest" element, the same element that was added into the queue most recently using enque()

// Pre: the queue is not empty

// Post: returns the element at the back of the queue

void enque(int newItem); // insert one element at the back of the queue, after its current last element (the "youngest" element before this enque)

// Post: newItem added at the end of the queue, after the current last element

int deque(); // remove one element from the front of the queue. The "oldest" element should be removed

// Pre: the queue is not empty

// Post: the item at the front of the queue is removed from the queue and returned

queue(int size = 100);

// Post: queue initialized with capacity being size and contains 0 elements.

// if no size is specified, 100 is used for the capacity

};

Answer this question:

Is it okay to remove the isEmpty() function from queue class and let users use the inherited isEmpty()? Thats what the unorderedArrayListType class does. Explain.

Overload the output operator << for the queue class so you can easily print out a queue (add function prologue, param type and pre-/post- comments). You have to overload it due to the private inheritance.

Add appropriate code into main to test your queue class (you may delete the existing code in main at this point). Be sure to test each function and print out current content of a queue object.

You should not directly access the int* list data member of the arrayListType class in your implementation such as use list or list[someIndex] Instead, you should call existing functions provided in the .cpp file.

You should not modify the given arrayListType / unorderedArrayListType code except for deleting the given main code and breaking the code into header + implementation (see next requirement).

click on the link below for snapshot of code

https://imgur.com/a/4enXnOm

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!