Why is this an issue?
It is not very common for a struct to have base classes. When they do, by default, they will have public inheritance. Since this is not a fact
known by everybody, it’s usually better to be explicit about the visibility of base classes in a struct.
Noncompliant code example
class B {
};
struct C : B {
};
Compliant solution
class B {
};
struct C : public B { // Or private, if it was public by mistake
};
Resources
Related rules
- S5965 is a similar rule that deals with base visibility in classes
- S3540 is another rule that favors a different coding style for base classes. It should not be activated at the same time as this
rule.