Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <string>
- /*zad1 - TOsoba*/
- using namespace std;
- class TAdres{
- private:
- string miasto;
- string ulica;
- int numer;
- public:
- TAdres(string city, string street, int nr);
- void Wyswietl();
- ~TAdres();
- };
- class TOsoba{
- protected:
- string imie;
- string nazwisko;
- int wiek;
- TAdres adres;
- public:
- TOsoba(string name, string surname, int age, string city, string street, int nr):adres(city, street, nr)
- {
- imie = name;
- nazwisko = surname;
- wiek = age;
- cout<<"Zostal wywolany konstruktor TOsoba!"<<endl;
- }
- virtual void Wyswietl() = 0;/*{
- cout<<imie<<" "<<nazwisko<<" lat "<<wiek<<","<<endl;
- cout<<"adres: ";
- adres.Wyswietl();
- cout<<endl;
- }*/
- string PodajImie(){
- return imie;
- }
- string PodajNazwisko(){
- return nazwisko;
- }
- ~TOsoba(){
- cout<<"Wywolalismy destruktor TOsoba!"<<endl;
- }
- };
- class TStudent: public TOsoba{
- private:
- string kierunek;
- int rok;
- public:
- TStudent(string name, string surname, int age, string city, string street, int nr, string kier, int year):TOsoba(name, surname, age, city, street, nr){
- kierunek = kier;
- rok = year;
- cout<<""<<endl;
- cout<<"Zostal wywolany konstruktor TStudent!"<<endl;
- }
- virtual void Wyswietl(){
- cout<<imie<<" "<<nazwisko<<" lat "<<wiek<<","<<endl;
- cout<<"adres: ";
- adres.Wyswietl();
- cout<<"kierunek studiow: "<<kierunek<<", rok: "<<rok<<endl;
- cout<<endl;
- }
- string PodajKierunek(){
- return kierunek;
- }
- ~TStudent(){
- cout<<"Zostal wywolany destruktor TStudent!"<<endl;
- }
- };
- TAdres::TAdres(string city, string street, int nr){
- miasto = city;
- ulica = street;
- numer = nr;
- cout<<"Zostal wywolany konstruktor TAdres!"<<endl;
- }
- void TAdres::Wyswietl(){
- cout<<miasto<<" "<<"ul."<<ulica<<" "<<numer<<endl;
- return;
- }
- TAdres::~TAdres(){
- cout<<"Wywolalismy destruktor TAdres!"<<endl;
- }
- //**********************************************
- int main() {
- TStudent st("Justyna", "Lachowska", 20, "Rejowiec", "Fabryczna", 12, "informatyka", 2);
- st.Wyswietl();
- TOsoba *wskaznik = new TStudent("Gosia", "Lesczuk", 21, "Lublin", "Romantyczna", 15, "informatyka", 2);
- wskaznik->Wyswietl();
- TOsoba &os = st;
- os.Wyswietl();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement