+ 1

Can anyone help me out from this

#include<iostream> #include<string> #include<queue> using namespace std; template <class T> class Queue { public : T capacity = 10; T front = 0; T rear = -1; T * queue = new T[capacity]; T Enqueue(T x) { if(rear == capacity - 1) { cout<<"Queue is full"<<endl; } else { rear++; queue[rear] = x; } return x; } T showQueue() { if(capacity == 0) { cout<<"Queue is empty"<<endl; } else { for(T i = front ; i <= rear ; i++) { cout<<queue[i]<<" <- "; } cout<<endl; } return 0; } template < > class Queue <string> { public : Queue(string name) { int i = 0; int f = 0; int r = -1; string name1 = name; } } }; int main() { Queue <int> q1; q1.Enqueue(42); q1.Enqueue(2); q1.Enqu

23rd Jan 2021, 7:10 AM
Om Nandgirwar
Om Nandgirwar - avatar
6 Answers
+ 5
Just go through the some previous lessons again. You will find the answer there
23rd Jan 2021, 7:14 AM
Arsenic
Arsenic - avatar
+ 3
You only have to make the class generic on type of data. I don't see the necessity to change the logic or function names of the given class.
23rd Jan 2021, 10:01 AM
Benjamin JĂŒrgens
Benjamin JĂŒrgens - avatar
+ 1
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.
23rd Jan 2021, 7:11 AM
Om Nandgirwar
Om Nandgirwar - avatar
+ 1
Can you help me guys for that code?😞😞
25th Jan 2021, 2:18 PM
John Lee Relatado Dialal
John Lee Relatado Dialal - avatar
0
I have tried a lot but I'm able to do the operation upto character variable only
23rd Jan 2021, 7:14 AM
Om Nandgirwar
Om Nandgirwar - avatar
0
But I want to accept the string
23rd Jan 2021, 7:15 AM
Om Nandgirwar
Om Nandgirwar - avatar