Class: Class is a blueprint or a set of instructions to build a specific type of object.
Object: Object is an instance of a class.
Generally class consists of constructor, data and methods.
Constructor → a special method (same name as class) used to instantiate (create) an object of class.
Date stored → State variable / Data Member / Property of that class
Actions performed → Method / Behaviour / Function of that class
Example:
Class: Car
Objects: Mercedes, BMW, Toyota
Data Member: Price, Speed, Wheels, Mileage, Model, Colour
Member Function: brakes(), accelerate(), start(), stop()
Four pillars of Object Oriented Programming:
- Abstraction
- Inheritance
- Encapsulation
- Polymorphism
Do a SOLID check whenever creating a class.