Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Pojazd
  5. {
  6. private :
  7. int przebieg;
  8. public:
  9. Pojazd():przebieg(0)
  10. {
  11. cout << " Konstruktor deflautowy " << endl;
  12. }
  13. Pojazd(const int& n) :przebieg(n)
  14. {
  15. cout << "Konstruktor parametryczny" << endl;
  16. }
  17. ~Pojazd()
  18. {
  19. cout << "Destruktor" << endl;
  20. }
  21. int GetPrzebieg()
  22. {
  23. return przebieg;
  24. }
  25. };
  26.  
  27. class Autobus : public virtual Pojazd
  28. {
  29. private:
  30. int LiczbaPasazerow;
  31. public :
  32. Autobus() :LiczbaPasazerow(0)
  33. {
  34. cout << " Konstruktor deflautowy (autobus) " << endl;
  35. }
  36. Autobus(const int& m) :LiczbaPasazerow(m), Pojazd(300)
  37. {
  38. cout << "Konstruktor parametryczny (autobus)" << endl;
  39. }
  40. Autobus(const int& l, const int& k)
  41. : LiczbaPasazerow(l), Pojazd(k)
  42. {
  43.  
  44. }
  45. ~Autobus()
  46. {
  47. cout << "Destruktor (autobus)" << endl;
  48. }
  49. int GetLiPasazerow()
  50. {
  51. return LiczbaPasazerow;
  52. }
  53.  
  54. };
  55.  
  56.  
  57. int main()
  58. {
  59. Pojazd poj = 100;
  60. cout << poj.GetPrzebieg() << endl;
  61. Autobus pas = 500;
  62. Autobus brum(400, 800);
  63. cout << pas.GetLiPasazerow() << " " << pas.GetPrzebieg() << endl;
  64. cout << brum.GetLiPasazerow() << " " << brum.GetPrzebieg() << endl;
  65. Autobus bus;
  66. bus = 3;
  67. cout << bus.GetLiPasazerow() << " " << bus.GetPrzebieg() << endl;
  68.  
  69.  
  70.  
  71.  
  72. return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement