1
0

workmi.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // workmi.cpp -- multiple inheritance
  2. // compile with workermi.cpp
  3. #include <iostream>
  4. #include <cstring>
  5. #include "workermi.h"
  6. const int SIZE = 5;
  7. int main()
  8. {
  9. using std::cin;
  10. using std::cout;
  11. using std::endl;
  12. using std::strchr;
  13. Worker * lolas[SIZE];
  14. int ct;
  15. for (ct = 0; ct < SIZE; ct++)
  16. {
  17. char choice;
  18. cout << "Enter the employee category:\n"
  19. << "w: waiter s: singer "
  20. << "t: singing waiter q: quit\n";
  21. cin >> choice;
  22. while (strchr("wstq", choice) == NULL)
  23. {
  24. cout << "Please enter a w, s, t, or q: ";
  25. cin >> choice;
  26. }
  27. if (choice == 'q')
  28. break;
  29. switch(choice)
  30. {
  31. case 'w': lolas[ct] = new Waiter;
  32. break;
  33. case 's': lolas[ct] = new Singer;
  34. break;
  35. case 't': lolas[ct] = new SingingWaiter;
  36. break;
  37. }
  38. cin.get();
  39. lolas[ct]->Set();
  40. }
  41. cout << "\nHere is your staff:\n";
  42. int i;
  43. for (i = 0; i < ct; i++)
  44. {
  45. cout << endl;
  46. lolas[i]->Show();
  47. }
  48. for (i = 0; i < ct; i++)
  49. delete lolas[i];
  50. cout << "Bye.\n";
  51. // cin.get();
  52. // cin.get();
  53. return 0;
  54. }