@Ganado -- it compiled for me in two online compilers (repl.it and the one from this site)
Out of curiosity, I opened up VS2015 and, indeed, with these two headers included it liked srand() but had no love for time() function. I began opening the include documents to put together the inclusion chain:
both <string> and <iostream> include <istream>
<istream> includes <ostream>
<ostream> includes <ios>
<ios> includes <xlocnum>
<xlocnum> includes <climits>, <cmath>, <cstdio>, <cstdlib>, <streambuf>
So since <cstdlib> gets pulled in, I can see why the srand() works, but I can't explain how the online compilers got the time() function working.
Edit: appears explicit inclusion of <ctime> may be necessary on windows, but for linux it gets automagically included with <iostream> to help with pthreads, as per this answer
https://stackoverflow.com/questions/8016646/why-does-iostream-include-time-h
Updated my answer to
#include <ctime>
.