Generation

generate functionTue, 17 Jan 2023

a counter as timer which has states start, stop, is expired

++ // C++ class Counter { private: int _startTime; int _stopTime; public: void start() { _startTime = time(NULL); } void stop() { _stopTime = time(NULL); } bool isExpired(int duration) { return _stopTime - _startTime > duration; } }

Questions about programming?Chat with your personal AI assistant