Advertisement
Holek

Untitled

May 7th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Licznik{
  5. protected:
  6.     int liczba;
  7. public:
  8.     Licznik(int l):liczba(l){}
  9.     get_liczba(){
  10.         return liczba;
  11.     }
  12.     void inkrementuj(){
  13.         liczba++;
  14.     }
  15. };
  16.  
  17. class LicznikOdZera : public Licznik{
  18. public:
  19.     LicznikOdZera():Licznik(liczba = 0){}
  20. };
  21.  
  22. main()
  23. {
  24.     Licznik a1(5);
  25.     cout << a1.get_liczba() << endl;
  26.     a1.inkrementuj();
  27.     cout << a1.get_liczba() << endl;
  28.     LicznikOdZera a2;
  29.     a1 = a2;
  30.     cout << a1.get_liczba() << endl;
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement