- 1

Can anyone guide me in this please

#include <iostream> 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 << "Queue is empty"<<endl; return; } else { for (int i = 0; i < size - 1; i++) { queue[i] = queue[i + 1]; } size--; } } void print() { if (size == 0) { cout << "Queue is empty"<<endl; return; } for (int i = 0; i < size; i++) { cout<<queue[i]<<" <- "; } cout << endl; } Queue operator+(Queue &obj) { Queue res; for(int i=0;i<this->size;i++) { res.add(this->queue[i]); } for(int i=0;i<obj.size;i++) { res.add(obj.queue[i]); } return res; } }; int main() { Queue<int> q1; q1.add(42); q1.add(2); q1.add(8); q1.add(1); q1.print(); Queue<string> q2; q2.add("Dave"); q2.

22nd Jan 2021, 6:59 PM
Om Nandgirwar
Om Nandgirwar - avatar
9 ответов
+ 2
Actually I am creating a template class by using template specialization for taking string as different generic type for updating in Queue management system in c++ course
22nd Jan 2021, 7:24 PM
Om Nandgirwar
Om Nandgirwar - avatar
+ 2
Adding to Martin's answer: Forth, there is no description what your code is supposed to do and what the problem is. Some people here are putting good efford into answering questions, so you should put at least some effort into asking properly. Your chances of getting the answer you need will also rise dramatically.
22nd Jan 2021, 7:25 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
+ 2
Ohk I will do it
22nd Jan 2021, 7:25 PM
Om Nandgirwar
Om Nandgirwar - avatar
+ 2
But that is just the code given by that challenge (minus the last 62 characters). Where is your attempt?
22nd Jan 2021, 7:39 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
+ 1
Plsss help me for this code🥺
25th Jan 2021, 1:20 PM
John Lee Relatado Dialal
John Lee Relatado Dialal - avatar
0
It's time to update your Queue management system. The previous version supports only integer numbers and we need to support more types, such as strings, to store customer names in the queue. Transform the given Queue class to a class template, which can work with different data types.
22nd Jan 2021, 7:27 PM
Om Nandgirwar
Om Nandgirwar - avatar
0
Hey there this is the question above plz guide me in this
22nd Jan 2021, 7:28 PM
Om Nandgirwar
Om Nandgirwar - avatar
0
Actually I have done it but I am not able to show you bcoz of my mobiles bad condition
22nd Jan 2021, 7:40 PM
Om Nandgirwar
Om Nandgirwar - avatar
0
Sorry, but I don't believe you. You copied the code given, so why shouldn't you be able to post your modified code. And if for some obscure reason that is actually true, you could at least describe your actual problem. I can't help you any more than telling you to go back and revise the lessons about class templates or follow the links from Martin Taylor
22nd Jan 2021, 7:45 PM
Benjamin Jürgens
Benjamin Jürgens - avatar