pdf.css
Google


   


You are here: CodeIdol > C++ > C/C++ Programming Style Guidelines > page: 1 2 3 4 5 6 7 8 9 10 11


And what person would be considered complete without having read The Elements of
Style
by Strunk and White?

2. File Contents
Use files to group functionality. Each file should contain only one cohesive set of
functions. Avoid duplicating functionality in separate files. If different files contain
similar functions, consider generalizing the function sufficiently and putting it into its
own file so that both function groups can use the one source. For C++ code, put only
one class or closely related set of classes in each file.

Avoid strong coupling between functions and classes implemented in separate files. If
two objects are so strongly coupled that one can only be used in conjunction with the
other then they belong in the same file.

Use header files (
.h
suffix) to declare public interfaces, use code files (
.c
,
.cc
or
.cpp
suffix) to define implementations. Typically each cohesive set of functions you write in
a single file will have one accompanying header/interface file pair. Code that uses your
implementation will

#include
the header file.
Be precise with
#include
statements. Explicitly include the
.h
files you require, and
only where you require them. If, for example, your code calls a function defined
externally, include that function's associated

.h
in your implementation file not in your
code's associated
.h
file. You should only need to include other files in your
.h
file if
your public function interface or data type definitions require the definitions contained
therein.

Avoid using header files to contain a set of
#include
directives simply for
convenience. This "nesting" of
#include
constructs obscures file dependencies from
the reader. It also creates a coupling between modules including the top-level header
file. Unless the modules are cohesively coupled functionally, and each requires all the

.h
files included in the convenience header, it is preferable to instead include all the
You are here: CodeIdol > C++ > C/C++ Programming Style Guidelines > page: 1 2 3 4 5 6 7 8 9 10 11


ADBRITE ads links
   
Related tags







Popular Categories
Unix books and guides

AJAX popular information
C# language guides
Windows books and cookbooks

.......








Business Key Top Sites

be number one
rate your site




    С 2009 года мы стали переводить структура сайта на различные языки. Сайт теперь будет содержать книги не только на английском языке, но также и на других европейских языках, в том числе и на Русском языке.

    Русский Polski Francais Deutsch
    support sitemap terms

© CodeIdol Labs, 2007 - 2009