-
Notifications
You must be signed in to change notification settings - Fork 767
Specifying constants and default values
Michael Burri edited this page Jan 7, 2015
·
5 revisions
Constants should be specified outside a class or struct in the header file with the following naming convention.
...
#include "some_include.h"
namespace yourNamespace {
// Constants should be prefixed with a k and written in camelCase.
static constexpr double kSomeConstant = 0.00135;
...
struct SomeStruct {};
class SomeClass {};
...
}
Default values should be constructed of constants initialized in the constructor as follows.
...
#include "some_include.h"
namespace yourNamespace {
// Constants should be prefixed with a k and written in camelCase.
static constexpr double kSomeConstant = 0.001;
// Default values should be prefixed with kDefault and also written in camelCase.
static constexpr double kDefaultYourVariableName = 0.002;
...
class SomeClass {
double your_variable_name_;
...
public:
// Member initialization with default values.
SomeClass()
: your_variable_name_(kDefaultYourVariableName),
... {}
...
};
...
}