Reputation: 31
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:)
Upvotes: 3
Views: 5809
Reputation: 98425
You are using a MSVC version that is too old. The error originates in the compiler, not in Qt Creator.
Upvotes: 1