fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. class catalog_books
  5. {
  6. private:
  7. std::string book_author;
  8. std::string book_name;
  9. int year;
  10. std::string group;
  11.  
  12. public:
  13. catalog_books() : book_author(), book_name(), year(), group() {};
  14.  
  15. catalog_books(std::string book_autor_, std::string book_name_, int year_, std::string group_) :
  16. book_author(book_autor_), book_name(book_name_), year(year_), group(group_) {};
  17.  
  18. std::string Getbook_author() const
  19. {
  20. return book_author;
  21. }
  22.  
  23. std::string Getbook_name() const
  24. {
  25. return book_name;
  26. }
  27.  
  28. int Getbook_year() const
  29. {
  30. return year;
  31. }
  32.  
  33. std::string Getbook_group() const
  34. {
  35. return group;
  36. }
  37.  
  38. };
  39.  
  40. std::ostream & operator << (std::ostream &out, const catalog_books & t)
  41. {
  42. out << t.Getbook_author() << " ";
  43. out << t.Getbook_name() << " ";
  44. out << t.Getbook_year() << " ";
  45. out << t.Getbook_group() << '\n';
  46. return out;
  47. }
  48.  
  49.  
  50. int main()
  51. {
  52. const size_t N = 3;
  53.  
  54.  
  55.  
  56. catalog_books books[N];
  57.  
  58. books[0] = { "Сенкевич", "Потоп", 1978, "Художественная"};
  59. books[1] = { "Ландау", "Механика", 1989, "Учебная" };
  60. books[2] = { "Дойль", "Сумчатые", 1990, "Справочная" };
  61.  
  62. for (size_t i = 0; i < N; ++i)
  63. {
  64. std::cout << books[i];
  65. }
  66.  
  67. }
Success #stdin #stdout 0s 4392KB
stdin
Standard input is empty
stdout
Сенкевич   Потоп   1978   Художественная
Ландау   Механика   1989   Учебная
Дойль   Сумчатые   1990   Справочная