Even if you write everything into one file, which simplifies life for non-experts, there is some structure that should be obeyed and that helps later to pull the code apart into several files. It is as follows:
{} // Global declarations/definitions. // This would become something like ``globals.h''. typedef double Time ; Time time = -1 ; ... // global utilities // This would become something like ``utils.h''. #include <stdlib.h> extern "C" double drand48() ; double myRand() { return drand48() ; } // Class declarations including definitions for ``short'' methods. // Each class would go into a separate *.h file. class Link ; // forward declaration class Node { private: Id id_ ; public: void set_id( Id val ) { id_ = val ; } // ``short'' method ... Link* findOutgoingLink( Id linkId ) ; // ``long'' method }; ... // Definitions of ``long'' class methods. // Methods for each class would go into a separate *.cpp file. Link* Node::findOutgoingLink( Id linkId ) { ... } ... // global functions (should be avoided; can normally go into ``class // SimWorld'' or similar) // main: void main() { ... }