Problem C1083: Unable to open include file: 'chrono': no ​​such file or directory is output

I am trying to make a program from which 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 exists"

It would be appreciated if you could help :)

+3


source to share


1 answer


You are using too old version of MSVC. The error occurs in the compiler, not in Qt Creator.



+1


source







All Articles