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
In C, you can make a struct, but you can’t make a function belong to the struct.
In C++, you can make a function that belongs to a class. You can make instances of that class call specific functions automatically upon construction or deconstruction. This lets you restrict what a developer is allowed to do or not do with your code. Less to think about and get wrong that way.
Latest Answers