Howdy folks....
I'm struggling to get my head around classes, specifically what's being taught in this lesson:
http://www.learncpp.com/cpp-tutorial/89-class-code-and-header-files/
Actually, i already put a question at the bottom of that page, and i'm copying also here, i'm hoping someone could set me straight on this!
Here's my question to the author of that page on learncpp.com:
----------------
I’m really failing to understand this chapter.
I don’t understand the difference between class "definition" and "implementation".
Your "class Date" example is actually longer (32 lines) then the original (26 lines) and i don’t see the benefit. Are the functions that are moved outside now placed in "int main()"?
To use the functionality of the class, you don’t need to look inside it at all do you? Isn’t that all done from "int main()"???
I don’t see the reason to move anything outside. I thought the benefits of classes (mentioned earlier) is that they package things up nicely and keep stuff out of sight, but in this lesson you’re recommending un-packaging them again!!
Same thing with the "class Calc" example, the original seems nice and compact, the second version seems a lot longer and harder to read.
I’m sure i’m just not getting something fundamental here. If possible, could you give a clear explanation of the difference between class "definitions" and "implementations"?