Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Auto1
  6. {
  7. public:
  8. string marka;
  9. string model;
  10. int rocznik;
  11.  
  12. void dodaj()
  13. {
  14. cout<<"Podaj informacje o samochodzie: "<<endl;
  15. cout<<"Podaj Marke: ";
  16. cin>> marka;
  17. cout<<"Podaj model: ";
  18. cin>> model;
  19. cout<<"Podaj rocznik: ";
  20. cin>> rocznik;
  21. }
  22. void wyswietl()
  23. {
  24. cout<<endl<< "Marka: "<< marka<<endl<< "Model: "<< model<<endl<< "Rocznik: "<< rocznik<<endl;
  25. }
  26.  
  27. };
  28.  
  29. class Auto2 :public Auto1
  30. {
  31. public:
  32. string kolor;
  33. int drzwi;
  34. int moc;
  35.  
  36. void dodaj()
  37. {
  38. Auto1::dodaj();
  39. cout<<endl<<"Podaj dodatkowe informacje na temat samochodu:"<<endl;
  40. cout<<"Podaj kolor: ";
  41. cin>> kolor;
  42. cout<<"Podaj liczbe drzwi: ";
  43. cin>> drzwi;
  44. cout<<"Podaj moc: ";
  45. cin>> moc;
  46. }
  47. void wyswietl2()
  48. {
  49. Auto1::wyswietl();
  50.  
  51. cout<< "Dodatkowe informacje:"<<endl<<"kolor: "<<kolor<<endl<< "Ilosc drzwi: "<<drzwi<<endl<< "Moc: "<<moc;
  52. }
  53.  
  54. };
  55.  
  56. int main()
  57. {
  58. Auto1 A1;
  59. //A1.dodaj();
  60. //A1.wyswietl();
  61.  
  62. Auto2 A2;
  63. A2.dodaj();
  64. A2.wyswietl2();
  65.  
  66.  
  67. return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement