Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Auto1
- {
- public:
- string marka;
- string model;
- int rocznik;
- void dodaj()
- {
- cout<<"Podaj informacje o samochodzie: "<<endl;
- cout<<"Podaj Marke: ";
- cin>> marka;
- cout<<"Podaj model: ";
- cin>> model;
- cout<<"Podaj rocznik: ";
- cin>> rocznik;
- }
- void wyswietl()
- {
- cout<<endl<< "Marka: "<< marka<<endl<< "Model: "<< model<<endl<< "Rocznik: "<< rocznik<<endl;
- }
- };
- class Auto2 :public Auto1
- {
- public:
- string kolor;
- int drzwi;
- int moc;
- void dodaj()
- {
- Auto1::dodaj();
- cout<<endl<<"Podaj dodatkowe informacje na temat samochodu:"<<endl;
- cout<<"Podaj kolor: ";
- cin>> kolor;
- cout<<"Podaj liczbe drzwi: ";
- cin>> drzwi;
- cout<<"Podaj moc: ";
- cin>> moc;
- }
- void wyswietl2()
- {
- Auto1::wyswietl();
- cout<< "Dodatkowe informacje:"<<endl<<"kolor: "<<kolor<<endl<< "Ilosc drzwi: "<<drzwi<<endl<< "Moc: "<<moc;
- }
- };
- int main()
- {
- Auto1 A1;
- //A1.dodaj();
- //A1.wyswietl();
- Auto2 A2;
- A2.dodaj();
- A2.wyswietl2();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement