问题C1083:无法打开包含文件:'chrono':没有这样的文件或目录弹出 [英] Issue C1083: cannot open include file: 'chrono': no such file or directory pops out
本文介绍了问题C1083:无法打开包含文件:'chrono':没有这样的文件或目录弹出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的.pro档案
QT + = core gui
greaterThan(QT_MAJOR_VERSION,4):QT + = widgets
TARGET = Lotto
TEMPLATE = app
CONFIG + = c ++ 11
SOURCES + = main.cpp\
mainwindow.cpp \
lottogenerator.cpp
HEADERS + = mainwindow.h \
lottogenerator.h
FORMS + = mainwindow.ui
这是我的.h文件
ifndef LOTTOGENERATOR_H
#define LOTTOGENERATOR_H
#include< string>
#include< random>
#include< array>
#include< chrono>
class LottoGenerator
{
public:
typedef std :: chrono :: high_resolution_clock myclock;
LottoGenerator();
std :: array< int,6>得到();
private:
int rand();
std :: mt19937 * engine;
std :: uniform_int_distribution< int>分配;
myclock :: time_point beginning = myclock :: now();
};
#endif // LOTTOGENERATOR_H
这是我的.cpp文件。 / p>
#includelottogenerator.h
LottoGenerator :: LottoGenerator()
:distribution (1,45)
{
myclock :: duration d = myclock :: now() - beginning;
unsigned int seed = d.count();
engine.seed(seed);
}
std :: array< int,6> LottoGenerator :: get()
{
std :: array< int,6>数字;
numbers [0] = rand();
numbers [1] = rand();
numbers [2] = rand();
numbers [3] = rand();
numbers [4] = rand();
numbers [5] = rand();
返回数字;
}
int LottoGenerator :: rand()
{
return distribution(engine);
}
当我运行时,C1083:无法打开包含文件:'chrono'
如果您能帮助我们,非常感谢。)
解决方案您使用的MSVC版本太旧。错误起源于编译器,而不是在Qt Creator。
I'm trying to make a program that makes 6 numbers come out randomly.
This is my .pro file
QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = Lotto TEMPLATE = app CONFIG += c++11 SOURCES += main.cpp\ mainwindow.cpp \ lottogenerator.cpp HEADERS += mainwindow.h \ lottogenerator.h FORMS += mainwindow.ui
This is my .h file
#ifndef LOTTOGENERATOR_H #define LOTTOGENERATOR_H #include <string> #include <random> #include <array> #include <chrono> class LottoGenerator { public: typedef std::chrono::high_resolution_clock myclock; LottoGenerator(); std::array<int, 6> get(); private: int rand(); std::mt19937 *engine; std::uniform_int_distribution<int> distribution; myclock::time_point beginning = myclock::now(); }; #endif // LOTTOGENERATOR_H
This is my .cpp file.
#include "lottogenerator.h" LottoGenerator::LottoGenerator() : distribution(1,45) { myclock::duration d = myclock::now() - beginning; unsigned int seed = d.count(); engine.seed(seed); } std::array<int, 6> LottoGenerator::get() { std::array<int, 6> numbers; numbers[0] = rand(); numbers[1] = rand(); numbers[2] = rand(); numbers[3] = rand(); numbers[4] = rand(); numbers[5] = rand(); return numbers; } int LottoGenerator::rand() { return distribution(engine); }
and when I run, "C1083: cannot open include file: 'chrono': no such file or directory" pops out.
It would be grateful if you could help:)
解决方案You are using a MSVC version that is too old. The error originates in the compiler, not in Qt Creator.
这篇关于问题C1083:无法打开包含文件:'chrono':没有这样的文件或目录弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文