iostream can include cstdlib directly or indirectly. This results in std::rand() and ::rand() . You are using the latter.
But yes, you should not rely on this and always include cstdlib if you want to use rand . And in C++ code does not use rand , there are more efficient ways to generate random numbers.
source share