Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class zwierze{
- private:
- string imie;
- public:
- static int licznik;
- zwierze(string imie_k)
- {
- imie=imie_k;
- licznik++ ;
- }
- void ustawImie(string imie_new)
- {
- imie=imie_new;
- }
- string naLancuch ()
- {
- string &ref=imie;
- return ref;
- }
- static int ileZwierzat()
- {
- return licznik;
- }
- };
- int zwierze::licznik=0;
- bool porownaj(zwierze z1,zwierze z2)
- {
- if(z1.naLancuch() == z2.naLancuch()) return true;
- else return false;
- }
- int main()
- {
- zwierze z3("Endrju");
- zwierze z1("Kasztan");
- zwierze z2("Spawymir");
- z1.ustawImie("Spawymir");
- cout<< z1.naLancuch()<<endl;
- cout<< z2.naLancuch()<<endl;
- cout<< porownaj(z1,z2)<<endl;
- cout<< zwierze::ileZwierzat() <<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement