jeudi 9 avril 2020

default_random_engine seed makes c++ interpret variable as a function [duplicate]

I'm trying to make random numbers inside a class with this code:

#pragma once
#include <random>
#include <ctime>

using namespace std;

class A
{
    default_random_engine engine(time(0));
};

Whenever I try to seed the default_random_engine, VS says that I haven't defined the function "engine". Even though the same code, outside the class, works just fine. If I don´t use a seed it says there's no mistake.

Note: I'm using a separate file for this class and this declaration is inside A.h but the same problem happens in the main function.




Aucun commentaire:

Enregistrer un commentaire