A non-POD type should be defined as class
A non-POD type should be defined as class.
A POD (Plain Old Data) type can be exchanged with C code in its binary form, and can be
safely copied by using the std::memcpy function. Scalar types, C-style
structures and unions, and arrays of these types are all examples of POD types. However, the
C++ language also allows you to create structures and unions that are non-POD types. Such
structures and unions can provide custom-defined constructors, have nonstatic data members
with private or protected access control, have an interface, and implement an
invariant.
A software developer typically expects object-oriented concepts such as encapsulation to be implemented by using classes. In addition, a class specifier forces the type to provide private access control for all its members by default and is naturally suited for implementing encapsulated types. So, to create easily readable and maintainable code, define a non-POD type as a class instead of a structure or a union.
The checker flags a structure or a union in your code is not a POD type. This includes structures and unions that are instantiated by using templates.
For a simplified explanation of a POD type in C++ language, see the previous section. For a full specification of a POD type, see the C++ reference manual.
If you expect a rule violation but do not see it, refer to Coding Standard Violations Not Displayed.
| Group: Member access control |
| Category: Advisory, Automated |