我需要在我的 C++ 程序中使用全局时间戳 (std::chrono::high_resolution_clock::now())。我在头文件Header.h中声明了它:
#include<chrono>
using namespace std;
extern auto start;
我想在 main 中初始化一个值,所以在 main.cpp 中,我做了:
#include"Header.h"
#include<chrono>
using namespace std;
auto start;
int main(){
start = std::chrono::high_resolution_clock::now();
}
然而,当编译它时,我得到:
error: declaration of ‘auto start’ has no initializer
谁能告诉我我做错了什么?谢谢!
How is auto
应该推断出类型start
?
您需要声明类型
extern std::chrono::high_resolution_clock::time_point start;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)