mercredi 7 avril 2021

How can I set up a random seed inside a class header file?

I'm trying to set srand(time(NULL)) inside my class which I have written in a header file. I tried putting it into constructors but it doesn't affect the rand()'s I call.

I also tried putting the srand(time(NULL)) in int main() but that only affects the randomizers if the class is defined in the same .cpp file as the main function.

So, I was wondering if there's anyway to set the seed if I'm using a header file?

Aucun commentaire:

Enregistrer un commentaire