Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. class Osoba{
  7. public:
  8. string imie;
  9. string nazwisko;
  10. int wiek;
  11.  
  12. Osoba(){
  13.  
  14. cout << "Podaj swoje dane osobowe" << endl;
  15. cout << "Imie: "<< endl;
  16. cin >> imie;
  17. cout << "Nazwisko: "<< endl;
  18. cin >> nazwisko;
  19. cout << "Wiek: "<< endl;
  20. cin >> wiek ;
  21. }
  22. void Wypisz()
  23. {
  24. cout << "Dane osobowe: " << endl;
  25. cout << imie <<" "<< nazwisko<< " " << wiek << " lat";
  26. }
  27.  
  28.  
  29. };
  30.  
  31. class Ksiazka: public Osoba{
  32.  
  33. public:
  34.  
  35. string tytul;
  36. Osoba autor;
  37.  
  38. Ksiazka(string t,Osoba a,string dw):autor(a) { // nadpisuje
  39. tytul = t;
  40. autor = a;
  41. data_wydania = dw;
  42.  
  43. }
  44.  
  45. string data_wydania;
  46.  
  47. void Wypisz()
  48. {
  49. cout << "Oto dane na temat ksiazek: " << endl;
  50. cout << tytul << " " << "" << " " << data_wydania << " " <<endl;
  51. }
  52. };
  53.  
  54.  
  55. class Czytelnik:public Osoba{// dziedziczenie
  56.  
  57.  
  58.  
  59.  
  60. Ksiazka lista_ksiazek[100]; // lista/tablica obiektów typu Książka
  61.  
  62. void Wypisz_Ksiazki()
  63. {
  64.  
  65. cout << "Oto ksiazki przeczytane przez: "<< imie << " " << nazwisko << endl;
  66. }
  67.  
  68. };
  69.  
  70.  
  71.  
  72.  
  73. int main()
  74. {
  75.  
  76. Osoba osoba1;//,osoba2,osoba3;
  77. Ksiazka horror("Przygody",autor("Marcin", "Lukasiewicz", 22), " 22 kwiecien 1998");
  78. Ksiazka dramat("sdasdsad",autor("Andrzej", "Lukasiewicz", 32), " 1 kwiecien 1968");
  79. Ksiazka powiesc("jezu",autor("blagam", "cie", 12), " 4 marzec 1968");
  80. Ksiazka historyczna("plisk",autor("sadsadm", "csade", 42), " 2 marzec 1998");
  81. Ksiazka scifi("zut",autor("ssad", "sae", 52), " 24 marzec 1999");
  82. osoba1.Wypisz();
  83.  
  84.  
  85.  
  86. return 0;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement