MISRAC++2023-14.1.1 (C++ only)
In this section:
Synopsis
(Advisory) Non-static data members should be either all private or all public
Enabled by default
No
Severity/Certainty
Medium/High

Full description
A mix of private and public members means that the encapsulation of data for class becomes unclear. This also goes for protected which is not allowed either.
Coding standards
This check does not correspond to any coding standard rules.
Code examples
The following code example fails the check and will give a warning:
class A // Non-compliant - has public and protected members
{
public:
int a;
protected:
int b;
};
The following code example passes the check and will not give a warning about this issue:
struct A // Compliant - pure data
{
int a;
int b;
};