Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Pojazd
- {
- private :
- int przebieg;
- public:
- Pojazd():przebieg(0)
- {
- cout << " Konstruktor deflautowy " << endl;
- }
- Pojazd(const int& n) :przebieg(n)
- {
- cout << "Konstruktor parametryczny" << endl;
- }
- ~Pojazd()
- {
- cout << "Destruktor" << endl;
- }
- int GetPrzebieg()
- {
- return przebieg;
- }
- };
- class Autobus : public virtual Pojazd
- {
- private:
- int LiczbaPasazerow;
- public :
- Autobus() :LiczbaPasazerow(0)
- {
- cout << " Konstruktor deflautowy (autobus) " << endl;
- }
- Autobus(const int& m) :LiczbaPasazerow(m), Pojazd(300)
- {
- cout << "Konstruktor parametryczny (autobus)" << endl;
- }
- Autobus(const int& l, const int& k)
- : LiczbaPasazerow(l), Pojazd(k)
- {
- }
- ~Autobus()
- {
- cout << "Destruktor (autobus)" << endl;
- }
- int GetLiPasazerow()
- {
- return LiczbaPasazerow;
- }
- };
- int main()
- {
- Pojazd poj = 100;
- cout << poj.GetPrzebieg() << endl;
- Autobus pas = 500;
- Autobus brum(400, 800);
- cout << pas.GetLiPasazerow() << " " << pas.GetPrzebieg() << endl;
- cout << brum.GetLiPasazerow() << " " << brum.GetPrzebieg() << endl;
- Autobus bus;
- bus = 3;
- cout << bus.GetLiPasazerow() << " " << bus.GetPrzebieg() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement