C++11 缺少类型说明符,还有一个问题

C++11 缺少类型说明符,还有一个问题,c++11,chrono,C++11,Chrono,我想做一个简短的计时声明 #pragma once #include <chrono> class Foo//: public SINGLETON<Foo> { public: using point = std::chrono::steady_clock::time_point; using secs = std::chrono::duration_cast<std::chrono::seconds>

我想做一个简短的计时声明

#pragma once
#include <chrono>

    class Foo//: public SINGLETON<Foo>
    {
    public:
        using point = std::chrono::steady_clock::time_point;
        using secs  = std::chrono::duration_cast<std::chrono::seconds>;
        using now   = std::chrono::steady_clock::now();
    };
现在有一个关于这些用法的问题,我想这样使用它们

time_point  GetElapsedtTime(){return time_secs(time_now - Another_time_point ); }
我可以像上面那样使用它们吗

我试图设置一个变量的时间点,然后倒计时,直到它达到1小时,例如,然后当1小时过去。。做点什么。

使用
(在此上下文中)相当于
typedef
。您正在为类型赋予新名称

这个:
使用point=std::chrono::stable\u clock::time\u point很好<代码>标准::时钟::稳定时钟::时间点
是一种类型;你正在改名

这个:
使用secs=std::chrono::duration\u cast不是,因为
std::chrono::duration\u cast
不是类型-它是一个函数

类似地,
std::chrono::staid_clock::now()不是一种类型。它是一个类型为
std::chrono::time\u point
的值

(这就是编译器给您的“不命名类型”消息所说的)

error: expected type-specifier
  using time_now   = std::chrono::steady_clock::now();
time_point  GetElapsedtTime(){return time_secs(time_now - Another_time_point ); }