Rewrite the interface file, the implementation file, and the application file for the Queue class (Program 1, Program 2, and Program 3) using an array created in the heap /**************************************************************** 2 * The application to test the Queue class * 3 ****************************************************************/ 4 #include "queue.cpp" 5 6 int main ( ) 7 { 8 // Instantiation of a queue object 9 Queue queue; 10 // Pushing four nodes into the queue 11 queue.push ("Henry"); 12 queue.push ("William"); 13 queue.push ("Tara"); 14 queue.push ("Richard"); 15 // Checking the element at the front and the back of the queue 16 cout << "Checking front and back elements"; 17 cout << "after four push operations:" << endl; 18 cout << "Element at the front: " << queue.front () << endl; 19 cout << "Element at the back: " << queue.back () << endl << endl; Program 2 File queue.cpp (continued) / Popping two elements from the queue 21 queue.pop (); 22 queue.pop (); 23 // Checking the front and the back node after two pop operations 24 cout << "Checking front and back elements"; 25 cout << "after two pop operations:" << endl; 26 cout << "Element at the front: " << queue.front () << endl; 27 cout << "Element at the back: " << queue.back () << endl; 28 return 0; 29 }
Rewrite the interface file, the implementation file, and the application file for the Queue class (Program 1, Program 2, and Program 3) using an array created in the heap /**************************************************************** 2 * The application to test the Queue class * 3 ****************************************************************/ 4 #include "queue.cpp" 5 6 int main ( ) 7 { 8 // Instantiation of a queue object 9 Queue queue; 10 // Pushing four nodes into the queue 11 queue.push ("Henry"); 12 queue.push ("William"); 13 queue.push ("Tara"); 14 queue.push ("Richard"); 15 // Checking the element at the front and the back of the queue 16 cout << "Checking front and back elements"; 17 cout << "after four push operations:" << endl; 18 cout << "Element at the front: " << queue.front () << endl; 19 cout << "Element at the back: " << queue.back () << endl << endl; Program 2 File queue.cpp (continued) / Popping two elements from the queue 21 queue.pop (); 22 queue.pop (); 23 // Checking the front and the back node after two pop operations 24 cout << "Checking front and back elements"; 25 cout << "after two pop operations:" << endl; 26 cout << "Element at the front: " << queue.front () << endl; 27 cout << "Element at the back: " << queue.back () << endl; 28 return 0; 29 }
Related questions
Question
Rewrite the interface file, the implementation file, and the application file
for the Queue class (Program 1, Program 2, and Program 3) using an array
created in the heap
for the Queue class (Program 1, Program 2, and Program 3) using an array
created in the heap
/****************************************************************
2 * The application to test the Queue class *
3 ****************************************************************/
4 #include "queue.cpp"
5
6 int main ( )
7 {
8 // Instantiation of a queue object
9 Queue <string> queue;
10 // Pushing four nodes into the queue
11 queue.push ("Henry");
12 queue.push ("William");
13 queue.push ("Tara");
14 queue.push ("Richard");
15 // Checking the element at the front and the back of the queue
16 cout << "Checking front and back elements";
17 cout << "after four push operations:" << endl;
18 cout << "Element at the front: " << queue.front () << endl;
19 cout << "Element at the back: " << queue.back () << endl << endl;
Program 2 File queue.cpp (continued)
2 * The application to test the Queue class *
3 ****************************************************************/
4 #include "queue.cpp"
5
6 int main ( )
7 {
8 // Instantiation of a queue object
9 Queue <string> queue;
10 // Pushing four nodes into the queue
11 queue.push ("Henry");
12 queue.push ("William");
13 queue.push ("Tara");
14 queue.push ("Richard");
15 // Checking the element at the front and the back of the queue
16 cout << "Checking front and back elements";
17 cout << "after four push operations:" << endl;
18 cout << "Element at the front: " << queue.front () << endl;
19 cout << "Element at the back: " << queue.back () << endl << endl;
Program 2 File queue.cpp (continued)
/ Popping two elements from the queue
21 queue.pop ();
22 queue.pop ();
23 // Checking the front and the back node after two pop operations
24 cout << "Checking front and back elements";
25 cout << "after two pop operations:" << endl;
26 cout << "Element at the front: " << queue.front () << endl;
27 cout << "Element at the back: " << queue.back () << endl;
28 return 0;
29 }
21 queue.pop ();
22 queue.pop ();
23 // Checking the front and the back node after two pop operations
24 cout << "Checking front and back elements";
25 cout << "after two pop operations:" << endl;
26 cout << "Element at the front: " << queue.front () << endl;
27 cout << "Element at the back: " << queue.back () << endl;
28 return 0;
29 }
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 3 images