0

[C++ Classes and Inheritance] Why do we have them?

As someone who is intermediately fluent in Bash, Python and VB; I'm used to the scripting languages, it's been a bit of a curve with a compiler but I think I'm catching on. I have yet to finish the course but I'm in the middle of inheritance and polymorphism. This is a lot of assumptions I am writing below, so the point I want to get to here is: Is anything that I am saying, correct, close, not correct at all? I have yet to start a C++ project but understanding why I am being taught classes I asked myself: Why do we use them? A couple of possible answers that came to mind is automating object "clean up" so to say. Now this is a bit tricky since I don't fully understand it yet but when a program no longer needs something in memory that object that is sitting in the memory register needs to be deleted. Out of context I see that classes and inheritance allows that to be easily automated. I'm very used to just writing python functions all over the place until it eventually becomes a patchwork of passing arguments through one another. So a second theory is classes allow for a lot of organization. Correct me if I am wrong. Edit: I'm used to scripting languages cleaning up the mess in memory for me at the expense of performance. Now that I'm introducing myself to compilers, I now have to keep memory/dynamic memory in mind. Is this the main concept that classes and inheritance help with?

8th Jan 2018, 8:05 AM
Jacob Yuhas
Jacob Yuhas - avatar
1 ответ
0
it there to reduce the errors in programmes even it very easy to acesd you can know when learn the basics of c++ clearly
8th Jan 2018, 3:02 PM
Satish
Satish - avatar