Documentation
Every function and class should be documented and thoroughly commented.
Use Doxygen standards, which CLion should automatically register and autocomplete.
https://www.doxygen.nl/index.html
Bracket usage
When using brackets, always do
void foo(params) { } //NOT void foo(params) { }
Class file ordering
Libraries on top and interfaces to other classes below, group these by type
Public goes above private in the .h
Function ordering in the .cpp should match the .h
#include <iostream> #include "ExampleClass.h" class DateClass { public: int mYear{}; int mMonth{}; int mDay{}; private: int mTime{}; };
Structs and enums
Do not use typedefs for structs.
Structs must also be used for data only.
struct Date { int year{}; int month{}; int day{}; }; //NOT typedef struct { int year{}; int month{}; int day{}; } Date;
Use enum class, not enum.
enum class Color { red, blue }; //NOT enum Color { red, blue };