Why is this an issue?
Adding an access specifier that matches the class' current access level needlessly clutters the code.
Noncompliant code example
struct B {
};
struct S : public B { // Noncompliant; "struct" has public access for its base classes by default
};
class C : private B { // Noncompliant; "class" has private access for its base classes by default
};
Compliant solution
struct B {
};
struct S : B {
};
class C : B {
};
Resources
Related rules
- S5965 and S5966 are other rules that favor different coding style for base classes. They should not be activated at the
same time as this rule.