This is a rather basic question, but it\'s one that\'s bugged me for awhile.
My project has a bunch of .cpp (Implementation) and .hpp (Definition) files.
I f
Check out John Lakos's Large-Scale C++ Software Design. Here's what I follow (written as an example):
// foo.h
// 1) standard include guards. DO NOT prefix with underscores.
#ifndef PROJECT_FOO_H
#define PROJECT_FOO_H
// 2) include all dependencies necessary for compilation
#include
// 3) prefer forward declaration to #include
class Bar;
class Baz;
#include // this STL way to forward-declare istream, ostream
class Foo { ... };
#endif
// foo.cxx
// 1) precompiled header, if your build environment supports it
#include "stdafx.h"
// 2) always include your own header file first
#include "foo.h"
// 3) include other project-local dependencies
#include "bar.h"
#include "baz.h"
// 4) include third-party dependencies
#include
#include
#include
#include
// stdafx.h
// 1) make this easy to disable, for testing
#ifdef USE_PCH
// 2) include all third-party dendencies. Do not reference any project-local headers.
#include
#include
#include
#include
#include
#include
#endif