Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

solve it. #include using namespace std; class Queue { int size; int* queue; public: Queue() { size = 0; queue = new int[100]; } void

image text in transcribed

solve it.

#include using namespace std; class Queue { int size; int* queue; public: Queue() { size = 0; queue = new int[100]; } void add(int data) { queue[size] = data; size++; } void remove() { if (size == 0) { cout return; } else { for (int i = 0; i queue[i] = queue[i + 1]; } size--; } } void print() { if (size == 0) { cout return; } for (int i = 0; i cout } cout } Queue operator+(Queue &obj) { Queue res; for(int i=0;isize;i++) { res.add(this->queue[i]); } for(int i=0;i res.add(obj.queue[i]); } return res; } }; //your code goes here int main() { Queue q1; q1.add(42); q1.add(2); q1.add(8); q1.add(1); q1.print(); Queue2 q2; q2.add(3); q2.add(66); q2.add(128); q2.add(5);q2.add(111);q2.add(77890); q2.print(); return 0; }

Queue Management +50 XP Your Queue class is up and working in a customer service company. The company opens up a new branch and asks you to make another version of the Queue for them. The only difference is the way the Queue is displayed: each number on a new line. You decide to create a new class called Queue2, which is derived from the Queue class and overrides the print() method, outputting each element of the queue on a new line. Do not forget to change the access specifier of the Queue members, as they won't be inherited if private

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 1 Lnai 9284

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Carlos Soares ,Joao Gama ,Alipio Jorge

1st Edition

3319235273, 978-3319235271

More Books

Students also viewed these Databases questions