Question: Create a node class/struct. Create a queue class/struct. Members: Node - a node that tracks the front of the queue. Node - a node that

Create a node class/struct. Create a queue class/struct. Members: Node - a node that tracks the front of the queue. Node - a node that tracks the end of the queue. Count - indicates how many items are on the queue. Methods: En-queue - Accepts a number and adds to the end of the queue. De-queue - Returns a number from the front of the queue. - If the queueis empty, emit an error indicating the queueis empty. IsEmpty - Returns a boolean indicating if the queue is empty.

this is my code so far

#include #include using namespace std; struct node { int info; struct node *next; }; class Queue{ private: node * rear; node * front; public: Queue (); void EnQueue (); void dequeue (); void Show (); }; Queue::Queue () { rear = 0; front = 0; } void Queue::EnQueue () { int data; node * temp = new node; cout << "Enter datas to EnQueue: "; cin >> data; temp->info = data; temp->next = 0; if (front == 0) { front = temp; } else{ rear->next = temp; } rear = temp; } void Queue::dequeue (){ node * temp = new node; if (front == 0){ cout << endl<else{ temp = front; front = front->next; cout <info<delete temp; } } void Queue::Show (){ node * p = new node; p = front; if (front == 0) { cout << "Npthing to show "<else{ while (p != 0) { cout << endl << p->info; p = p->next; } } } int main () { Queue queue; int choice; while (true) { cout << " 1.EnQueue 2. Dequeue 3. Show  4.Quit"; cout << "  Enter your choice: "; cin >> choice; switch (choice) { case 1: queue.EnQueue (); break; case 2: queue.dequeue (); break; case 3: queue.Show (); break; case 4: exit (0); break; default: cout << " Invalid Input. Try again!  "; break; } } return 0; }

please add a count member

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!