Encapsulation
class Bird { string name, color, gender; public: Bird(string n, string c, string g) { name = n; color = c; gender = g; }
};
int main() {
Bird b("gauraiya", "brown", "female");
return 0;
}
The above code has three problem:
- Dirty code.
- Client have to remember the sequence of parameter.
- Backward compatibility.
Problems can be solved using Builder pattern.