...
Code Block | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
#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 | ||||
---|---|---|---|---|
| ||||
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 | ||||
---|---|---|---|---|
| ||||
enum class Color {
red,
blue
};
//NOT
enum Color {
red,
blue
}; |