{
                  
                  
                      private:
                  
                  
                          string book;
                  
                  
                          float price;
                  
                  
                      public:
                  
                  
                          virtual void getdata()
                  
                  
                              {
                  
                  
                                  cout << "Enter name of book: "; cin >> book;
                  
                  
                                  cout << "Enter price of book: "; cin >> price;
                  
                  
                              }
                  
                  
                          virtual void put_data()
                  
                  
                              {
                  
                  
                                  cout << "Book name: " << book << endl;
                  
                  
                                  cout << "Price: " << price;
                  
                  
                              }
                  
                  
                      };
                  
                  
                  class book : public publication
                  
                  
                      {
                  
                  
                      private:
                  
                  
                          int pages;
                  
                  
                      public:
                  
                  
                          void getdata()
                  
                  
                              {
                  
                  
                                  publication::getdata();
                  
                  
                                  cout << "Enter amount of pages "; cin >> pages;
                  
                  
                              }
                  
                  
                          void putdata()
                  
                  
                              {
                  
                  
                                  publication::put_data();
                  
                  
                                  cout << "Pages: " << pages;
                  
                  
                              }
                  
                  
                  
                  
                  
                      };
                  
                  
                  class tape : public publication
                  
                  
                      {
                  
                  
                      private:
                  
                  
                          float len;
                  
                  
                      public:
                  
                  
                          void get_data()
                  
                  
                              {
                  
                  
                                  publication::getdata();
                  
                  
                                  cout << "Enter time of playing "; cin >> len;
                  
                  
                              }
                  
                  
                          void put_data()
                  
                  
                              {
                  
                  
                                  publication::put_data();
                  
                  
                                  cout << "Time of playing: " << len;
                  
                  
                              }
                  
                  
                  
                  
                  
                      };
                  
                  
                  
                  
                  
                  int main()
                  
                  
                      {
                  
                  
                              publication*pubarr[100];
                  
                  
                              int n = 0;
                  
                  
                              char choise;
                  
                  
                              do{
                  
                  
                                  cout << "Enter information about book or tape? b/t ";cin >> choise;
                  
                  
                                  if (choise == 'b')
                  
                  
                                  {
                  
                  
                                      pubarr [n] == new book;
                  
                  
                                  }else
                  
                  
                                   pubarr[n] == new tape;
                  
                  
                                   pubarr[n++] -> getdata();
                  
                  
                  
                  
                  
                                  cout << "Continue?";
                  
                  
                                  cin >> choise;
                  
                  
                              }while (choise == 'y');
                  
                  
                              for (int i = 0; i < n; i++)
                  
                  
                                  pubarr[i] -> put_data();
                  
                  
                              cout << endl;
                  
                  
                              return 0;
                  
                  
                      }
                  
                  
                
Оберните код в теги: 3 символа ` до и после кода (в случае одиночной конструкции достаточно 1 ` с обеих сторон). Спасибо!
Обсуждают сегодня