Rule Definition
By implementing class interfaces with member functions, the implementation retains more control over how the object state can be modified and helps to allow a class to be maintained without affecting clients.
Remediation
Declare the data members of non-POD classes as Private
Violation Code Sample
Example
class C
{
.
.
.
.
public:
int32_t b; // Non-compliant
protected:
int32_t c; // Non-compliant
.
.
.}
Fixed Code Sample
{
.
.
private:
int32_t d; // Compliant
.
.
}
Reference
AUTOSAR C++, 2014, M11-0-1: Member data in non-POD class types shall be private.
MISRA C++ 2008, 11-0-1: Member data in non-POD class types shall be private.
https://scc.ustc.edu.cn/zlsc/chinagrid/intel/ssadiag_docs/GUID-F51536D1-92E6-4A21-9CCD-57612A8BA41E.htm
Related Technologies
Technical Criterion
Programming Practices - Modularity and OO Encapsulation Conformity
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.