I can’t really wrap my head around OOP. Like I understand an array and a function and a variable, but I don’t understand what an object is. Why can’t we just use functions and variables everytime we need information or code to run? I code in Python and JS mainly, so objects are truly the most important thing, but I don’t really get it. Also, isn’t every program object orientated? Even C, does it not fit the definitions? If so, how is it any different from C++?
In: Technology
Imagine you have different toys: cars, dolls, and blocks. Each toy is a different type, but they all have things in common. For example, all cars have wheels, and all dolls have clothes. In OOP, we call each type of toy a **class**, and when you make a toy, it’s called an **object**.
A class is like a blueprint. It tells you what a car or doll can do. Then, when you make a toy from that blueprint, that’s the object.
You can make lots of toy cars from the car blueprint, and each one can be a different color but still have wheels and doors.
Latest Answers