【发布时间】:2016-05-10 23:06:19
【问题描述】:
我正在开发一个类Timer,它的一些成员是high_resolution_clock::time_point 类型,其中time_point 定义为typedef chrono::time_point<system_clock> time_point;
问题
这个对象的默认值是多少?
我需要了解这个价值有几个原因:
- 了解成员是否已初始化
- 实现
Timer::Reset()函数
背景
class Timer
{
void Start() { m_tpStop = high_resolution_clock::now(); }
void Stop() { m_tpStart = high_resolution_clock::now(); }
bool WasStarted() { /* TO-DO */ }
void Reset();
__int64 GetDuration();
high_resolution_clock::time_point m_tpStart;
high_resolution_clock::time_point m_tpStop;
};
那么,我可以通过只查看成员m_tpStart 来实现Timer::WasStarted 吗?我不想为此添加布尔成员。
【问题讨论】:
-
你想让
Timer::Reset()做什么?重置计时器是什么意思? -
我刚刚更新了这个问题。请看课程本身。希望它会清除它。
-
@user2079303,我了解
Timer::Reset()函数需要更多详细信息。因此,为简单起见,让我们专注于函数Timer::WasStarted的实现。能否以简单的方式实现?