Originally Posted by T74marcell
I would actually put the standard headers before your own headers, like:
I think that is setting a maintenance land mine.
The original issue is that the OP put a line in x.h that won't compile unless iostream and/or fstream precedes that line.
The OP's answer was to move that problem line out of x.h and put it in a .c file where the required headers have already been read. That work's but it isn't a good answer.
Your answer was change the include order so that any .c that includes x.h includes iostream and fstream first. I think that answer is even worse.
If x.h includes any line what won't compile without iostream and fstream, then x.h itself should include iostream and fstream.
One of the coding standards where I work is that every .hpp file is coded so that it can compile even if it is the first thing included by some .cpp. That means a lot of .hpp files reinclude the same headers that other .hpp files have already included. But include guards work well to deal with that, and the alternative of a lot of complicated rules for include sequence is worse.