According to the book I\'m reading, rand() requires #include in C++
However, I am able to compile the following code that uses
iostream may include cstdlib directly or indirectly. This brings std::rand() and ::rand() in the scope. You are using the latter one.
But yes, you should not count on this and always include cstdlib if you want to use rand. And in C++ code don't use rand, there are better ways to generate random numbers.