Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Stop
- {
- bool isRunning;
- clock_t time1;
- clock_t time2;
- double seconds;
- public:
- //Construct and initialise
- Stop();
- //Return current time of stopwatch
- void getTime();
- //Press button 1 to start or stop counting
- void pushButtonStartStop();
- //Press button 2 to reset time
- void pushButtonReset();
- };
- void Stop::pushButtonStartStop()
- {
- if(isRunning == false)
- {
- isRunning = true;
- time1 = clock();
- }
- else
- {
- isRunning = false;
- time2 = clock();
- seconds += ((double)(time2-time1)/ CLOCKS_PER_SEC);
- }
- }
- Stop watch;
- watch.pushButtonStartStop();
- for(long i = 0; i< 100000000;i++)
- {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement