hat_to_the_back
hat_to_the_back

Reputation: 291

C++ Printing out function

I am trying to create a total random number between a set of integers but I have no idea how to print the result:

 mt19937 mt_rand(time(0));
 mt19937::result_type seed = time(0);
 auto dice_rand = std::bind(std::uniform_int_distribution<int>(1,6),
                           mt19937(seed));
 std::function<int()> dice3 = std::bind(std::uniform_int_distribution<int>(1,6),
                                        mt19937(seed));

    int x = dice3;
    qDebug()<< "Result" << x ;

I keep getting errors because of type INT. I am new to C++ and QT. How can I print out an INT? I have tried printing dice_rand, then I tried to convert it to a std::fucntion but I still can't seem to print it.

Upvotes: 0

Views: 109

Answers (1)

Hamadr
Hamadr

Reputation: 141

dice3 is a function. You should call it.

int x = dice3();

Upvotes: 7

Related Questions