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.


== Noncompliant Code Example

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


== Compliant Solution

----
class C
{
public:
  int32_t getB() { return _b; }
  void setB(int32_t b) { _b = b; }
protected:
  int32_t getC() { return _c; }
  void setC(int32_t c) { _c = c; }
private:
  int32_t _b; // Compliant
  int32_t _c; // Compliant
  int32_t _d; // Compliant
};
----


== See

* MISRA {cpp}:2008, 11-0-1


ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
