Question: Define a QueueTp template.Test it by creating a queue of pointers-to-Worker (as defined in Listing 14.10) and using the queue in a program similar to
Define a QueueTp template.Test it by creating a queue of pointers-to-Worker (as defined in Listing 14.10) and using the queue in a program similar to that in Listing 14.12.

Here is a sample run of the program in Listings 14.10, 14.11, and 14.12:
Enter the employee category:
w: waiter s: singer t: singing waiter q: quit
w
Enter waiter's name: Wally Slipshod
Enter worker's ID: 1040
Enter waiter's panache rating: 4
Enter the employee category:
w: waiter s: singer t: singing waiter q: quit
s
Enter singer's name: Sinclair Parma
Enter worker's ID: 1044
Enter number for singer's vocal range:
0: other 1: alto 2: contralto 3: soprano
4: bass 5: baritone 6: tenor
5
Enter the employee category:
w: waiter s: singer t: singing waiter q: quit
t
Enter singing waiter's name: Natasha Gargalova
Enter worker's ID: 1021
Enter waiter's panache rating: 6
Enter number for singer's vocal range:
0: other 1: alto 2: contralto 3: soprano
4: bass 5: baritone 6: tenor
3
Enter the employee category:
w: waiter s: singer t: singing waiter q: quit
q
Here is your staff:
Category: waiter
Name: Wally Slipshod
Employee ID: 1040
Panache rating: 4
Category: singer
Name: Sinclair Parma
Employee ID: 1044
Vocal range: baritone
Category: singing waiter
Name: Natasha Gargalova
Employee ID: 1021
Vocal range: soprano
Panache rating: 6
Bye.
Let’s look at a few more matters concerning MI.
Listing 14.12 workmi.cpp // workmi.cpp - multiple inheritance. // compile with workermi.cpp #include #include #include "workermi.h" const int SIZE = 5; int main() { using std::cin; using std::cout; using std::endl; using std::strchr; Worker lolas [SIZE]; int ct; for (ct = 0; ct < SIZE; ct++) { } char choice; cout < < "Enter the employee category: " < < "W: waiter s: singer < < "t: singing waiter q: quit "; cin >> choice; while (strchr("wstq", choice) == NULL) { } if (choice == 'g') break; } cout < < "Please enter a w, s, t, or q: "; cin >> choice; switch (choice) { case 'w': case 's': case 't': cin.get(); lolas [ct]->Set (); lolas [ct] new Waiter; break; lolas [ct] new Singer; break; lolas [ct] new singingwaiter; break; " cout < < " Here is your staff: "; int i; for (i = 0; i < ct; i++) { cout < < endl; lolas [1]->show(); } for (i = 0; i < ct; i++) delete lolas [i]; cout < < "Bye. "; return 0;
Step by Step Solution
3.40 Rating (153 Votes )
There are 3 Steps involved in it
QueueTp is a template class which is used to create a queue of objects It can st... View full answer
Get step-by-step solutions from verified subject matter experts
