fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. class Ksiazka
  5. {
  6. private:
  7. std::string tytul;
  8. std::string autor;
  9. int iloscStron;
  10. double cena;
  11.  
  12. public:
  13. void wypiszKsiazke()
  14. {
  15. std::cout << "Tytuł: " << tytul << std::endl;
  16. std::cout << "Autor: " << autor << std::endl;
  17. std::cout << "Ilość stron: " << iloscStron << std::endl;
  18. std::cout << "Cena: " << cena << std::endl;
  19. }
  20.  
  21.  
  22. void stworzKsiazke(std::string tytul2, std::string autor2,
  23. int iloscStron2, double cena2)
  24. {
  25. tytul = tytul2;
  26. autor = autor2;
  27. iloscStron = iloscStron2;
  28. cena = cena2;
  29. }
  30. };
  31.  
  32. int main()
  33. {
  34. const int ILOSC_KSIAZEK = 5;
  35. Ksiazka ksiazki[ILOSC_KSIAZEK];
  36.  
  37. ksiazki[0].stworzKsiazke("Hobbit, czyli tam i z powrotem",
  38. "J.R.R. Tolkien", 300, 25.0);
  39. ksiazki[1].stworzKsiazke("Drużyna pierścienia", "J.R.R. Tolkien", 500,
  40. 40.0);
  41. ksiazki[2].stworzKsiazke("Kroniki Amberu", "Roger Zelazny", 550, 40.0);
  42. ksiazki[3].stworzKsiazke("Diuna", "F. Herbert", 600, 50.5);
  43. ksiazki[4].stworzKsiazke("Kroniki Jakuba Wędrowycza", "Andrzej Pilipiuk",
  44. 350, 36.25);
  45.  
  46. for (int i = 0; i < ILOSC_KSIAZEK; ++i)
  47. {
  48. ksiazki[i].wypiszKsiazke();
  49. }
  50.  
  51. return 0;
  52. }
  53.  
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Tytuł: Hobbit, czyli tam i z powrotem
Autor: J.R.R. Tolkien
Ilość stron: 300
Cena: 25
Tytuł: Drużyna pierścienia
Autor: J.R.R. Tolkien
Ilość stron: 500
Cena: 40
Tytuł: Kroniki Amberu
Autor: Roger Zelazny
Ilość stron: 550
Cena: 40
Tytuł: Diuna
Autor: F. Herbert
Ilość stron: 600
Cena: 50.5
Tytuł: Kroniki Jakuba Wędrowycza
Autor: Andrzej Pilipiuk
Ilość stron: 350
Cena: 36.25