readability-redundant-access-specifiers.rst 1022 Bytes

readability-redundant-access-specifiers

Finds classes, structs, and unions containing redundant member (field and method) access specifiers.

Example

class Foo {
public:
  int x;
  int y;
public:
  int z;
protected:
  int a;
public:
  int c;
}

In the example above, the second public declaration can be removed without any changes of behavior.

Options

Example

struct Bar {
public:
  int x;
}

If CheckFirstDeclaration option is enabled, a warning about redundant access specifier will be emitted, because public is the default member access for structs.