class Osoba
{
public:
string imie;
string nazwisko;
virtual void create() = 0;
virtual void show() = 0;
virtual void remove() = 0;
};
class Wlasciciel : public Osoba
{
private:
string nazwaHotelu;
long long nr_tel;
public:
void create();
void show();
void remove();
//operator =
Wlasciciel operator=(const Wlasciciel& w)
{
imie = w.imie;
nazwisko = w.nazwisko;
nazwaHotelu = w.nazwaHotelu;
nr_tel = w.nr_tel;
return *this;
}
};
void Wlasciciel::create()
{
cout << "Podaj imie:" << endl;
cin >> imie;
cout << "Podaj nazwisko:" << endl;
cin >> nazwisko;
cout << "Podaj nazwe hotelu" << endl;
cin >> nazwaHotelu;
cout << "Podaj nr telefonu:" << endl;
cin >> nr_tel;
}
void Wlasciciel::show()
{
cout << imie << " " << nazwisko << " " << nazwaHotelu << " " << nr_tel << endl;
}
void Wlasciciel::remove(){}
class Person : public Osoba
{
public:
//operator =
Person operator=(const Person& p)
{
numerPokoju = p.numerPokoju;
arrivalDate = p.arrivalDate;
leavingDate = p.leavingDate;
return *this;
}
int numerPokoju;
Date arrivalDate;
Date leavingDate;
void create();
void show();
void remove();
};
void Person::create()
{
int day, month, year;
cout << "Imie: ";
cin >> imie;
cout << "Nazwisko: ";
cin >> nazwisko;
cout << "Dzien przyjazdu: ";
cin >> day;
cout << "Miesiac przyjazdu: ";
cin >> month;
cout << "Rok przyjazdu: ";
cin >> year;
arrivalDate = Date(day, month, year);
cout << "Dzien odjazdu: ";
cin >> day;
cout << "Miesiac odjazdu: ";
cin >> month;
cout << "Rok odjazdu: ";
cin >> year;
leavingDate = Date(day, month, year);
}
void Person::show()
{
cout << imie << " " << nazwisko << endl;
}
void Person::remove(){}
int main()
{
vector<Wlasciciel> wlasciciele;
vector<Osoba*> osoby; // ?
vector<Hotel> hotele;
Witam,
muszę dodać polimorfizm do swojego kodu, prowadzący dodał mi na zajęciach vector<Osoba*> osoby; . Nie bardzo wiem jak. Będę wdzięczna za wskazówkę.