Versions Compared

Key

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

...

Each member of an initialization list should be placed on a separate line. However, if the initialization list consists of one element, it can be kept on the same line. Colons in class definitions should be surrounded with spaces.

Code Block
languagecpp
structclass A
{
    int foo = 0;

protected:
    int bar = 1;

public:
    A(int const std::int32_t arg_foo) : foo(arg_foo) { }

    A(int const std::int32_t arg_foo, int const std::int32_t arg_bar) :
        foo(arg_foo),
        bar(arg_bar)
    { }

protected:
    std::int32_t bar = 1;

private:
    std::int32_t foo = 0;
};

Note that some older sources use a different convention that is now deprecated, due to the fact that it could not be enforced with autoformatters.

...