According to the book I'm reading, rand()
requires #include <cstdlib>
in C++
However, I am able to compile the following code that uses rand()
without #include <cstdlib>
nor using namespace std;
in Visual Studio 2015.
Why are these two not needed to compile? Should I include cstdlib?
C++ Code:
#include <iostream>
int main()
{
std::cout << rand() << std::endl;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…