| Aspect | Procedural (e.g. C) | Object-Oriented (e.g. C++) |
|---|---|---|
| Organizing unit | Functions | Objects (data + functions bundled together) |
| Data & function relationship | Separate — data passed between free-standing functions | Coupled — data and the functions that operate on it live inside one class |
| Data security | Global data freely accessible, error-prone | Access control via private/protected/public |
| Code reuse | Copy-paste or function reuse | Inheritance — extend existing classes without rewriting |
| Real-world modeling | Step-by-step procedures | Entities/objects, closer to how real systems are structured |
The defining characteristic examiners look for: OOP models a system as a set of interacting objects, each bundling its own data and behavior, rather than as a sequence of procedures acting on shared data.
class Account
{
private:
double balance;
public:
Account(double initial) : balance(initial) {}
void deposit(double amt) { balance += amt; }
double getBalance() const { return balance; }
};
A single class bundling data (balance) and behavior (deposit, getBalance) — this bundling is the core shift from procedural code.
Examiners ask "what is THE main characteristic of OOP" expecting a single, precise answer — not a list of the four pillars. The precise answer: OOP organizes a program around objects (bundled data + behavior) rather than around a sequence of procedures acting on shared data. Everything else (encapsulation, inheritance, polymorphism) follows from this one structural shift.
Procedural approach — data and functions are separate:
struct Account { double balance; };
void deposit(struct Account* a, double amt) { a->balance += amt; }
// Any function anywhere can touch a->balance directly -- no protection
OOP approach — data and functions are bundled, access is controlled:
class Account
{
private:
double balance;
public:
void deposit(double amt) { balance += amt; } // only this class can touch balance directly
};
Car object behaves like an actual car conceptually, aiding design and communication among developersstruct Account with a free function deposit(Account*, double) is an example of: