Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #pragma once
- class Timer
- {
- private:
- unsigned long start_time;
- public:
- Timer();
- void reset(int time_to_add);
- bool expired();
- };
- Timer::Timer()
- {
- this->start_time = clock();
- }
- void Timer::reset(int time_to_add)
- {
- this->start_time = ((clock() - this->start_time) / (int)CLOCKS_PER_SEC) + time_to_add;
- }
- bool Timer::expired()
- {
- return ((clock() - this->start_time) / (int)CLOCKS_PER_SEC) > this->start_time;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement