AutosarC++17_03-M11.0.1

Member data in non-POD class types shall be private

Required inputs: IR

Rationale

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.

Example
class C 
{
public:
int32_t b; // Non-compliant
protected:
int32_t c; // Non-compliant
private:
int32_t d; // Compliant
};

Note

For legal reasons, this rule’s description is not part of the public documentation.