Class
Blueprint or template for creating objects in OOP.
In [object-oriented programming](/en/terms/object-oriented-programming) (OOP), a class encapsulates data and behavior into a single unit. It serves as a blueprint from which individual objects (instances) are created, sharing the same structure but maintaining their own state.
graph LR
Center["Class"]:::main
Pre_object_oriented_programming["object-oriented-programming"]:::pre --> Center
click Pre_object_oriented_programming "/terms/object-oriented-programming"
Rel_object["object"]:::related -.-> Center
click Rel_object "/terms/object"
classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
linkStyle default stroke:#4b5563,stroke-width:2px;
🧠 Knowledge Check
1 / 5
🧒 Explain Like I'm 5
Think of a class as a cookie cutter. The cutter defines the shape (the class), but each cookie you make with it is a separate [object](/en/terms/object).
🤓 Expert Deep Dive
Classes enable core OOP features like inheritance, encapsulation, and polymorphism. Implementation usually involves a vtable for dynamic dispatch. Abstract classes provide interfaces without full implementation.
🔗 Related Terms
Prerequisites: