On 2016-02-16 14:03, Joe Bentley wrote:
> Is the <cstdlib> header file required? I have noticed that in some
> implementations it appears to be automatically included. Maybe it's
> up by <iostream> or some other common header file, but I can't find any
> reference on this. Does the "standard" have anything to say on its
> inclusion by other header files?
You should include the headers of the things you use. That's the simple
The standard says that any C++ header may include any other C++ header,
as needed. Relying on one header including some other header makes your
code non-portable, as the next compiler might include another set of
For <iostream> in particular, the standard makes an exception and
explicitly requires these includes:
Whether any of those in turn includes <cstdlib> is not specified.