C/C++ Programming Style Guidelines



error("The value is too big.");
}
Although the brackets may seem tedious for one-line blocks, they greatly reduce the
probability of errors being introduced when the block is expanded later in the code's
life.

3.1. Unique to C++
Start
public
,
protected
,
private
, and
friend
labels in column zero of class
declarations. Use explicit
public
labels for all
struct
public fields and use explicit
private
labels for all private class members.
The members of a class should be declared in the following order. Declare all public
data members and type definitions first. Declare private or protected data members or
type definitions used in function member initialization lists or inline implementations
next. Declare all public member functions next, starting with the constructors and
destructor. Declare all remaining private or protected data members and type definitions
next. Declare all private or protected function members next. Declare all friends last.

Put simple inline function definitions on the same line as their declaration. For inline
functions spanning multiple lines, use a pure-block style with four-space indentation.
In general, avoid putting complex function implementations

.h
files.
Example 6. Class declaration format
class Type : public Parent {
private:
int x_;
int y_;
public:
Type();
Type(int x) : x_(x) { }
~Type();