Sınıf, yapı (alanlar) ve davranış (yöntemler) tanımlayan bir şablondur veya taslaktır. Nesne (veya örnek), bu şablondan inşa edilen ve bellekte kendi değerlerine sahip somut bir şeydir.
Şablon ve örnek
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")
Kodda
python
:
():
.color = color
.speed =
():
.speed +=
a = Car()
b = Car()
a.accelerate()
(a.speed, b.speed)
(a.color b.color)
