الفئة هي نموذج أو قالب يحدد البنية (الحقول) والسلوك (الطرق). الكائن (أو النسخة) هو شيء ملموس مبني من ذلك النموذج، بقيمه الخاصة في الذاكرة.
النموذج مقابل النسخة
text
class Car ← ONE definition (the blueprint)
│ fields: color, speed
│ methods: accelerate()
▼
new Car("red") ← many OBJECTS (instances), each with its own state
new Car("blue")
في الكود
python
:
():
.color = color
.speed =
():
.speed +=
a = Car()
b = Car()
a.accelerate()
(a.speed, b.speed)
(a.color b.color)
