See the definitions for case-naming and examples.
This section is a far from complete but the basics are there at least.
Header files are clean and contain functions and class declarations having documentation blocks (Doxygen) and do not contain definitions to keep them clean and easy to read.
A distinction is made between inline and non-inline definitions.
Contains the definitions of template functions or class methods and inlined functions or class methods declared in the header file.
Contain the definitions of the functions and class methods declared in the header files.
The example is using the Allman code styling of braces which roughly translates to a .clang-format
file like below.
BasedOnStyle: LLVM
BraceWrapping:
AfterFunction: true
AfterControlStatement: true
AfterClass: true
SplitEmptyFunction: false
SplitEmptyRecord: false
IndentWidth: 4
Filename according convention is ArgumentMultiplier.h
.
/**
* @brief Just a defined maximum length.
*/
#define LENGTH_MAX 200
/**
* @brief Another length but now as global constant.
*/
constexpr int LENGTH_MIN{100};
// Linux namespace.
namespace lnx
{
/**
* @brief Class multiplying two arguments.
*/
class ArgumentMultiplier
{
public:
/**
* @brief Constructor passing 2 arguments.
* Arguments are in 'Lower Snake Case'.
*/
ArgumentMultiplier(int argument_one, int argument_two);
/**
* @brief Gets the result of the multiplication.
*/
[[nodiscard]] int getResult() const
{
return _argumentOne * _argumentTwo;
};
/**
* @brief Result of the multiplication.
* Enumerate types receive an 'E' prefix.
*/
enum EResultType: int
{
/** Result of the multiplication is negative. */
rtNegative = -1,
/** Result of the multiplication is zero. */
rtZero = 0,
/** Result of the multiplication is positive. */
rtPositive = 1,
};
/**
* @brief Type of result after multiplication.
*/
EResultType resultType{rtZero};
private:
/**
* @brief Stored argument 1 passed in constructor.
* A private or protected data member gets a underscore '_' prefix.
*/
int _argumentOne{0};
/**
* @brief Stored argument 2 passed in constructor.
*/
int _argumentTwo{0};
};
}