Advertisement
DesertFoxy

Untitled

Apr 23rd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5. int n;
  6. class Book {
  7. int max;
  8. string *auth;
  9. string name, surname, secname;
  10. int yotb, books;
  11. public:
  12. void add();
  13. void del();
  14. void count();
  15. Book() {
  16.  
  17. cout << "\nNumber of authors:";
  18. cin >> max;
  19. auth = new string[max];
  20. }
  21. };
  22.  
  23. void Book::add(){
  24. for (int i = 0; i < max; i++) {
  25. cout << "\nPerson " << i + 1 << endl;
  26. cin.get();
  27. cout << "\nName:";
  28. getline(cin, name);
  29. cout << "\nSurname:";
  30. getline(cin, surname);
  31. cout << "\nSecond name:";
  32. getline(cin, secname);
  33. cout << "\nBirth year:";
  34. cin >> yotb;
  35. cout << "\nNumber of books:";
  36. cin >> books;
  37. }
  38. }
  39.  
  40. void Book::del(){
  41. string del_surname;
  42. cout << "Give me a surname";
  43. cin.get();
  44. getline(cin, del_surname);
  45. if (del_surname == surname) {
  46. name = NULL;
  47. }
  48. }
  49.  
  50. void Book::count()
  51. {
  52. cout << "Number of authors:" << max;
  53. }
  54.  
  55. int main() {
  56.  
  57. Book A, D, C;
  58.  
  59. while (true){
  60. cout << "\n1.Add author\n2.Delete author\n3.Count authors\n0.Exit\n";
  61. int z;
  62. cin >> z;
  63. switch (z) {
  64. case 1: {
  65. cout << "\nEntering info:";
  66. A.add();
  67. break;
  68. }
  69. case 2:
  70. D.del();
  71. break;
  72. case 3:
  73. C.count();
  74. break;
  75. case 0:
  76. return 1;
  77. break;
  78. default:
  79. break;
  80. }
  81. }
  82.  
  83. system("pause");
  84. return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement