General Question
How can I reset the clock in this (C++) timer function?
Asked by t3h_87der (6)
August 22nd, 2010
Here’s the code:
——————————————————————
#ifndef TIMER
#define TIMER
#include <ctime>
bool reset = false;
class Timer {
clock_t counter;
public:
Timer(): counter(0) {};
bool elapsed(clock_t ms)
{
clock_t tick = std::clock();
if(tick – counter >= ms)
{
counter = tick;
return true;
}
return false;
}
};
#endif
————————————-
My question is how can I reset the time held in this function back to 0? This is a piece of code that my friend sent me to use for a program im working on, and it works great but i cant reset it. All answers are appreciated.
Observing members:
0
Composing members:
0
4 Answers
Answer this question
This question is in the General Section. Responses must be helpful and on-topic.
Have a question?
Ask Fluther!