Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Question I need this queue code converted to an STL Queue. The code works as is but needs changed to stl queue. Here are

C++ Question

I need this queue code converted to an STL Queue. The code works as is but needs changed to stl queue.

Here are is the header and mail file:

//Queue.h

#include using namespace std; struct queueNode{ string name; int ID; string major; struct queueNode *next; }; typedef queueNode* queueNodePtr; class queue { public: queue(){ front=NULL; back=NULL; } queue(const queue& aQueue){ this->front = aQueue.front; this->back = aQueue.back; } ~queue(){ front=NULL; back=NULL; } void add(queueNodePtr s){ if(back ==NULL){ back=s; front=back; back->next=NULL; return; } back->next = s; back=s; back->next=NULL; } queueNodePtr remove(){ if(front==NULL)return NULL; queueNodePtr temp = front; if(front==back){ front=NULL; back=NULL; return temp; } front=front->next; return temp; } bool empty(){ return front==NULL; } void display(){ queueNodePtr temp=front; while(temp){ cout<ID<<"\t"<name<<"\t"<major<<" "; temp=temp->next; } cout<<" "; } private: queueNodePtr front; queueNodePtr back; };

//main.cpp

#include"Queue.h" #include using namespace std;

int main(){ //Students queueNodePtr s1,s2,s3,s4,s5; //Student 1 s1 = new queueNode; s1->ID = 123; s1->name="Bob"; s1->major= "CS";

//Student 2 s2 = new queueNode; s2->ID = 456; s2->name="Bill"; s2->major= "Math";

//Student 3 s3 = new queueNode; s3->ID = 789; s3->name="Abe"; s3->major= "Biology";

//Student 4 s4 = new queueNode; s4->ID = 444; s4->name="Joe"; s4->major= "CS";

//Student 5 s5 = new queueNode; s5->ID = 555; s5->name="John"; s5->major= "Nursing"; queue q; q.add(s1); q.add(s2); q.add(s3); q.add(s4); q.add(s5); cout << "ID: Name: Major:"<< endl << endl; q.display(); return 0; system("pause");

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

0764532545, 978-0764532542

More Books

Students also viewed these Databases questions

Question

Distinguish between poor and good positive and neutral messages.

Answered: 1 week ago

Question

Describe the four specific guidelines for using the direct plan.

Answered: 1 week ago