I'm trying to do this exercise, which is to make 5 bunny objects for beginning,and each needs to be male or female,and according to it's sex, it receives male or female name.
Names and sex should be random.
My problem is that despite of the way I'm using to create new objects, each object receive the same name and sex. What could be the problem?
srand uses the argument passed to it to generate a pseudo-random number that rand then bases all of it's values off of. Because you are re-initializing srand at every call to "GetRandom()" and you are seeding it with the current time, which doesn't change in the amount of time it takes to run this program, you are effectively resetting this random number.