Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as text by m ( 17 years ago )
#include <iostream>



using namespace std;


static int licznik = 0;

class Czlowiek{
private:
string imie;
string nazwisko;

int wiek;

public: 
Czlowiek();
~Czlowiek();
void Przedstaw();
void Dane();
int ID;

}; // Czlowiek

class Zwierze : public Czlowiek{
private:
string rodzaj;
string nazwa;
int wiek;

public:
Zwierze();
~Zwierze();
void Przedstaw();
void Dane();

};





void Czlowiek::Dane(){
cout << endl << "Podaj swoje imie: ";
cin >> imie;
getchar();

cout << endl << "Podaj swoje nazwisko: ";
cin >> nazwisko;
getchar();

cout << endl << "Ile masz lat? : ";
cin >> wiek;
getchar();

};

void Czlowiek::Przedstaw(){
cout << endl << "Witaj ";
cout << endl << "Nazywasz sie " << imie << " " << nazwisko;
cout << endl << "Masz " << wiek << " lat.";
cout << endl << "Twoje ID to: " << ID;
};

Czlowiek::Czlowiek(){
licznik++;
ID = licznik; 
};

Czlowiek::~Czlowiek(){ 
cout << endl << "Destruktor Czlowiek"; 
};

Zwierze::Zwierze(){
licznik++;
ID = licznik; 
};

Zwierze::~Zwierze(){ 
cout << endl << "Destruktor Zwierze"; 
};

void Zwierze::Dane(){
cout << endl << "Jakiego masz zwierzaka? : ";
cin >> rodzaj;
getchar();

cout << endl << "Jak sie nazywa Twoj " << rodzaj << " ?: ";
cin >> nazwa;
getchar();
cout << endl << "Ile ma lat " << nazwa << " ? : ";
cin >> wiek; 
getchar(); 
};

void Zwierze::Przedstaw(){
cout << endl << " Masz " << rodzaj;
cout << endl << "Twoj " << rodzaj << " nazywa sie " << nazwa;
cout << endl << "Ma " << wiek << " lat";
};














int main(){

Czlowiek o1;
Zwierze z1; 

cout << "Dane dla 1 osoby" << endl;
o1.Dane();
cout << "Dane dla 1 Zwierzaka" << endl;
z1.Dane();


o1.Przedstaw();
z1.Przedstaw();

getchar();
return 0; 
}// main

 

Revise this Paste

Your Name: Code Language: