If you are using C++11, you can use the random header for this. You will need to create a generator, then define a distribution over this generator, and then you can use the generator and the distribution to get your results. You need to include random
#include <random>
Then define the generator and your distribution
std::default_random_engine generator;
std::uniform_real_distribution<double> distribution(-1,1); //doubles from -1 to 1
Then you can get random numbers like so
double random_number = distribution(generator);
If you need more information it is available here http://www.cplusplus.com/reference/random/