Question
1. For the following problem define a class QueueNode with data of type std::string. Also define a class Queue with two pointers: one for the
1. For the following problem define a class QueueNode with data of type std::string. Also define a class Queue with two pointers: one for the head and one for the tail. Both pointers are QueueNode * types. Implement the following operations for your queue data structure:
1. isEmpty() a predicate function which checks to see if the queue is empty; returns true if the queue is empty; false otherwise
2. enqueue() inserts a node into the queue at the tail; the node is allocated dynamically on the heap using the C++ operator new; returns true if the memory was allocated for a node, false otherwise 3. dequeue() deletes a node from the head of the queue using the C++ operator delete; returns the data in the node; precondition: queue is not empty (isEmpty () must be called before dequeue () is called)
4. printQueueRecursive() recursively prints out the data in the queue You should also consider any constructors/destructors, overloaded operators, and getters/setters that you need.
2. Test your application. In the same project, create one more header file testQueue.h and source file testQueue.cpp (for a total of at least five files). The testQueue.h file should contain function prototypes for test functions you will use on your queue functions. The testQueue.cpp source file should contain the implementations for these test functions. You will have at least one test function per application function. For example, you will have an application function called enqueue() (or a function very similar) that is used to insert a node into the queue at the tail. In this task, you will need to create a test function called testEnqueue() that passes in various data directly into enqueue() to see if it works as intended. You will also want to test these functions on empty and non-empty queues.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started