0

Queue management part 1, What is the lacking of this code??

#include <iostream> using namespace std; class Queue { int size; int* queue; public: Queue() { size = 0; queue = new int[100]; } 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; } //your code goes here }; int main() { Queue q; q.add(42); q.add(2); q.add(8); q.add(1); q.print(); q.remove(); q.add(128); q.print(); q.remove(); q.remove(); q.print(); return 0; }

12th Sep 2021, 5:49 AM
Jonalyn E. Lawis
Jonalyn E. Lawis - avatar
1 Respuesta
0
You should write your own code for the function "add". Cause just the function "add" remaining. Notice that in this code lines, it's written that "//your code goes here". You should write your code there and run it. Happy coding!
12th Sep 2021, 11:06 AM
mesarthim
mesarthim - avatar