The Directive said:
My personal preference is the reverse:
1.) standard library include files
2.) 3rd party include files
3.) my own include files
4.) the project include files
--The Directive
Thanks to Lakos "Large Scale C++" for pointing out to me that regardless of
the order of the rest every .cpp should always
include its own .h file first.
The reason: If you do this then every compile checks that the .h file stands
on its own as it should (i.e. does not require other headers and or using
directives to be included before it).
eg. the most common problem is that you get X.cpp defining ostream&
operator<<(ostream&,X&) and not including
<iostream> or <iosfwd> or not fully qualifying the names such that it will
only compile if all headers use:
#include <iostream.h> // i.e. <iostream> using std::iostream;
#include "X.h"
If this strategy is followed consistently then it gaurantees (at least where
there is a cpp for each .h) that the order of the rest does not matter.
This is so useful that I have a policy of creating a trivial cpp file for
every .h even though all it contains is a #include of the header.
Having started with "X.h" aesthetics would tend to favour the order
FIRST "X.h"