-
srand() Clarification
I'm having some problems with random numbers, so I just wanted to double-check this:
My main() function contains an object MyClassObject.
MyClassObject contains a member variable MySecondClassObject;
If I call srand(time(NULL)) in my main() function, then calling rand() from either of my classes should produce a newly randomized list each time I call the program, correct? (I don't have to call srand() in the constructor of each of my classes or anything?)
-
Correct. Unless the constructors are executed out of order (which they shouldn't be), you should be fine.
To the best of my knowledge :)
-
Mmkay, that's what I was assuming. Looks like it's back to the drawing board then. I've been trying to figure this problem out for the last couple of hours (srand() not actually randomizing, you know, the classic "I can't generate random numbers" problem, but somehow, this one's special and unlike any other), and if I still can't in the next few days, expect to see me back here :)
Thanks