In modern C++, the use of rand()
and srand()
is not recommended.
You should use the C++11 <random>
library instead.
Here you can get a good overview why <random>
is better than rand()
.
Regarding your problem:
You can simply seed every random engine you want to use (e.g. std::default_radom_engine
) with std::random_device
whereever you want and should be save, or just use different engines (can be of the same type) in the different parts of your code and seed every one of them once.