169. Encapsulation

Question.5

A developer makes every member private and adds getters and setters for all of them.

class Config {
   int baud;
   int parity;
   int stop_bits;
public:
   int getBaud() { return baud; }
   void setBaud(int b) { baud = b; } // No validation!
   int getParity() { return parity; }
   void setParity(int p) { parity = p; } // No validation!
};

Does this achieve meaningful encapsulation?

Need Help? Refer to the Quick Guide below

Select Answer

Restart quiz!