For me:
- Using declarations
- Private typedefs
- Private enumerations
- Private constants
- Private classes
- Public typedefs
- Public enumerations
- Public constants
- Public classes
- Private member variables
- Public member variables
- Private member functions (ctors, dtors, assignments, modifying functions, status functions, comparison functions)
- Public member functions (ctors, dtors, assignments, modifying functions, status functions, comparison functions)
- Friend declarations
- Free function operator overloads for class and class members (outside of class)
I prefer to not have ambiguity: it keeps me from having to wonder.
As for why... I am not sure. I feel that types are first. For functions, I read documentation, but for types, I feel that gleaning the header file is more likely, since there are few parameters or other such intricacies, unlike with functions. So, using declarations and types at the top. I put member variables in the middle, before functions; chances are, you aren't supposed to pay attention to those, so having them in the center, while types and the interface are on the extremeties, makes sense to me, and because of the old C (and other languagues') paradigm of putting variables at the top of the block, before everything. I feel that private should go before public, because of the default member access of classes, and habit. I sort member functions by their purpose, as noted above. Free functions generally go last, due to reliance on types declared earlier in the translation unit.
I also sort type and variable declarations.
...What?