Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct Counter //Licznik do liczenia
- {
- int counter; //licznik
- int dc; //o ile zwiekszyć
- int Id;
- void reset() // resetowanie licznika
- {
- counter=0;
- dc=1;
- }
- void show() //wyswietlanie licznika
- {
- cout<<"Stan licznika: "<<counter<<endl;
- }
- void add()// dodawawnie do licznika
- {
- counter+=dc;
- }
- void sub()// odejmowanie od licznika
- {
- counter -=dc;
- }
- void setCounter(int value)//ustawienie wartości
- {
- counter=value;
- }
- void setDc(int value) //usrawuenie przyrostu
- {
- dc=value;
- }
- void setID(int value) //usprawnienie jeżeli chodzi o numeracje liczników by odróźnić
- {
- Id=value;
- }
- };
- int main()
- {
- Counter c1={10,1,1};
- Counter c2={0,5,2};
- c1.add();
- c1.show();
- c2.add();
- c2.show();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment