Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
The process of bundling data and the functions that operate on that data into a single unit (a class). It protects data from unauthorized access.
class BankAccount {
private:
double balance; // Hidden data
public:
void deposit(double amt) {
if (amt > 0) balance += amt;
}
double getBalance() { return balance; }
};Prevents accidental modification of internal state by external code.
You can add validation logic inside setter functions to ensure data integrity.
An object is like a black box. Users know WHAT it does (through its public interface) but not HOW it does it (the private implementation).