વર્ગ એક બ્લુપ્રિન્ટ અથવા ટેમ્પ્લેટ છે જે સ્ટ્રક્ચર (ક્ષેત્રો) અને વર્તન (પદ્ધતિઓ) વ્યાખ્યાયિત કરે છે. પદાર્થ (અથવા ઇન્સ્ટન્સ) એ તે બ્લુપ્રિન્ટમાંથી બનેલી મૂર્ત વસ્તુ છે, મેમરીમાં તેના પોતાના મૂલ્યો સાથે.
બ્લુપ્રિન્ટ વર્સેસ ઇન્સ્ટન્સ
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)
