I've made it pretty far without having to use classes, or even know how to use them if I had to. Now just for the sake of organization, I think I should learn how to use classes. For those of you that use classes, is it a big advantage over structs?
I've made it pretty far without having to use classes, or even know how to use them if I had to. Now just for the sake of organization, I think I should learn how to use classes. For those of you that use classes, is it a big advantage over structs?
It all depends on what you are doing. If you are writing a very simple program that doesn't really need classes surely do not feel obligated to use them. However, some programs lend themselves to inheritance in a particularly nice way. For instance you can have an abstract base class with certain private members and a pure virtual function called Render( ). Then you can have different objects derive from it and over-ride the Render function to their own specifications. Can you just make them structs and have a Render( ) functions , sure. Say you are writing a math library with points, vectors, etc. Obviously you can have vectors derive from points for their components. Somethings just lend themselves to classes easier I think.
Encapsulating functionality in self contained classes sees most benefit when program/system size increases. It is not generally difficult to keep track of what is going on in a program of a few thousand lines, but when you get up to, say, half a million lines or more, it really is a big task to keep on top of.
Of course, classes are just one of the newer ways of doing this. Professional programmers have been modularising projects for this reason for years.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.