Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagecpp
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

Code Block
languagecpp
#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.

Code Block
themeDJango
languagecpp
struct Date {
    int year{};
    int month{};
    int day{};
};
//NOT
typedef struct {
    int year{};
    int month{};
    int day{};
} Date;

Use enum class, not enum.

Code Block
themeDJango
languagecpp
enum class Color {
    red,
    blue
};
//NOT
enum Color {
    red,
    blue
};