Versions Compared

Key

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

...

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

using, not typedef       

Use the using type alias rather than typedef:

Code Block
languagecpp
using distance_t = double; // define distance_t as an alias for type double
//NOT
typedef double distance_t; // define distance_t as an alias for type double

const, not define

Avoid using #define to create symbolic constants macros.

Code Block
languagecpp
const double GRAVITY{ 9.8 }; // preferred use of const before type

Naming conventions

  • Variables are camelCase.

  • Methods are camelCase.

  • Classes are PascalCase.

  • Static constants are UPPER_SNAKE_CASE.

Code Block
themeEmacs
languagecpp
class EncodedPacket {
    public:
        EncodedPacket(uint8_t *data, uint8_t len);
        const uint8_t *getData() const;
        uint8_t getLen() const;
        DecodedPacket *decode();

    private:
        const uint8_t * const data;
        const uint8_t len;
        Static const 
        void print(){
            std::cout << "This is a function!";
        }
};