A type defined as struct shall: (1) provide only public data members, (2) not provide any special member functions or methods, (3) not be a base of another struct or class, (4) not inherit from another struct or class
A type defined as struct shall: (1) provide only public data members, (2) not provide any special member functions or methods, (3) not be a base of another struct or class, (4) not inherit from another struct or class.
The items prohibited by this rule are not supported for struct types
in C code. In C++, a struct type can have private data members, member
functions, be inherited and inherit from other struct-s or
class-es. However, a developer typically associates these features with
a class type. Adhering to this rule makes sure that you use only classes
to implement object oriented concepts such as data encapsulation and inheritance.
Adhering to this rule also makes sure that your struct types conform
to the rules of Plain Old Data (POD) types and can be exchanged with C code.
The checker flags struct types with one or more of these features:
Contains private or protected data members.
struct members are public by default.
Contains member functions.
Acts as base class for another struct or
class, or inherits from another struct or
class.
If you expect a rule violation but do not see it, refer to Coding Standard Violations Not Displayed.
| Group: Member access control |
| Category: Required, Automated |