Why class include header should always be last in .cpp?

Wondering why at 4:26 we are told to put the “Grabber.h” last in the header include list in “Grabber.cpp”? I’ve coded off and on in C++ for many years and have always put the class header first in .cpp files as I would think you would want to go most specific to least specific (putting standard ones last). Doing a bit of googling and others look to follow this mostly as well in the C++ community as a whole. Haven’t run into any build issues yet… :crossed_fingers:

Is there something about Unreal that makes putting your header last more correct. I know that if you don’t have order-dependent headers (which isn’t a good thing) then it shouldn’t matter as everything gets concatenated into one giant file anyways after the pre-processor step. Is it something to do with the “generated” header that gets included transitively from the “Grabber.h” and that just like in the header file the cpp file should have these last as well?

Privacy & Terms