Table of Contents

  • Header Files
    • The #define Guard
    • Forward Declarations
    • Inline Functions
    • The -inl.h Files
    • Function Parameter Ordering
    • Names and Order of Includes
  • Scoping
    • Namespaces
    • Nested Classes
    • Nonmember, Static Member, and Global Functions
    • Local Variables
    • Static and Global Variables
  • Classes
    • Dong Work in Constructors
    • Initialization
    • Explicit Constructors
    • Copy Constructors
    • Delegating and Inheriting Constructors
    • Structs v.s. Classes
    • Inheritance
    • Multiple Inheritance
    • Interfaces
    • Operator Overloading
    • Access Control
    • Declaration Order
    • Write Short Functions
  • Google-Specific Magic
    • Ownship and Smart Pointers
    • Cpplink
  • Other C++ Features
    • Reference Arguments
    • Rvalue references
    • Function Overloading
    • Default Arguments
    • Variable-Length Arrays and alloca()
    • Friends
    • Exceptions
    • Run-Time Type Information(RTTI)
    • Casting
    • Streams
    • Preincrement and Predecrement
    • Use of const
    • Use of constexpr
    • Integer Types
    • 64-bit Portability
    • Preprocessor Macros
    • 0 and nullptr/NULL
    • sizeof
    • auto
    • Brace Initialization
    • Lambda Expressions
    • Boost
    • C++11
  • Naming
    • General Naming Rules
    • File Names
    • Type Names
    • Variable Names
    • Constant Names
    • Function names
    • Namespace Names
    • Enumerator Names
    • Macro Names
    • Exceptions to Naming Rules
  • Comments
    • Comment Style
    • File Comments
    • Class Comments
    • Function Comments
    • Variable Comments
    • Implementation Comments
    • Punctuation, Spelling and Grammar
    • TODO Comments
    • Deprecation Comments
  • Formatting
    • Line Length
    • Non-ASCII Characters
    • Spaces vs. Tabs
    • Function Declarations and Definitions
    • Function Calls
    • Braced Initializer Lists
    • Conditionals
    • Loops and Switch Statements
    • Pointer and Reference Expressions
    • Boolean Expressions
    • Return Values
    • Variable and Array Initialization
    • Preprocessor Directives
    • Class Format
    • Constructor Initializer Lists
    • Namespace Formatting
    • Horizontal Whitespace
    • Vertical Whitespace
  • Exceptions to the Rules
    • Existing Non-confomant Code
    • Windows Code

Background:

  • Style:
    • Readability, the conventions that gonvern the C++ code
    • Enforcing consistency to manage code
    • Some cases constrain or even ban, use of certain features.

Header Files:

  • Generally, every .cc file should have a .h file, except for unittests and small .cc files contain just one main() function.