Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class zwierze{
- string imie;
- static int liczba;
- public:
- zwierze( string im){
- imie = im;
- liczba++;
- }
- void ustawImie(){
- cout << " Podaj imie zwierzecia: " << endl;
- cin >> imie;
- }
- const string& naLancuch(){ // zwraca stala ref
- return imie;
- }
- static int ileZwierzat(){
- return liczba;
- }
- };
- int zwierze::liczba=0;
- bool porownanie(zwierze z1, zwierze z2){
- if(z1.naLancuch() == z2.naLancuch()) return true;
- else return false;
- }
- int main()
- {
- zwierze z1("Tadek");
- zwierze z2("Henri");
- cout << " Jak nazywa sie pierwsze zwierze? " << z1.naLancuch() << endl;
- cout << " Jak nazywa sie drugie zwierze? " << z2.naLancuch() << endl;
- cout << porownanie(z1, z2) << endl;
- cout << " Zmiana imienia pierwszego zwierzecia " << endl;
- z1.ustawImie();
- cout << " Jak nazywa sie pierwsze zwierze? " << z1.naLancuch() << endl;
- cout << " Jak nazywa sie drugie zwierze? " << z2.naLancuch() << endl;
- cout << porownanie(z1, z2) << endl;
- cout << " Liczba zwierzat wynosi: " << zwierze::ileZwierzat() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement