Class vs Object
A class is a Blue print of an object. a general concept (like an Animal), an object is a very specific embodiment of that class, with a limited lifespan (like a lion, cat, or a zebra).
Class
- Definition: Class is mechanism of binding data members and associated methods in a single unit.
- Existence: It is logical existence
- Lifespan: Classes do not have a lifespan
- Memory Allocation: Memory space is not allocated , when it is created.
- Declaration/Definition: Definition is created once.
Object
- Definition: Instance of class or variable of class.
- Existence: It is physical existence
- Lifespan: Objects have a lifespan
- Memory Allocation: Memory space is allocated, when it is created.
- Declaration/Definition: it is created many time as you require.