So, for a little behind the scenes action. The previous post about Header Files was originally going to be about classes. But then after I started writing, I realized if I continued on to talking about classes, the post was going to be longer than I would want to read, so I decided to just split off the header file topic entirely, and save more discussion of classes for later. That’s why I wrote about such an esoteric topic as “Header Files”. I also like the word esoteric, so expect that to show up in this blog every so often.
Anyway, back to what I originally was going to write about, classes. Classes are probably the most important thing in object oriented programming. They are the very constructs that objects are created from. For a physical analogy, lets say that we want to make a “landVehicle” class, by which I mean somethign that could discuss land vehicles like cars, trucks, tanks, whatever.
Aspects of Land Vehicles
- They have variable speeds to drive at
- They have an external color
- They can drive different directions
So, if we had a game that needed land vehicles in it, we may want to write a class that describes them, so that the game can display them or use them somehow. The first two describe an specific attribute of the land vehicle, while the third one refers to something it can do. In a class, those first two could be stored as variables, and the third one could be used as a method, to cause the vehicle to drive a certain direction. We’ve covered methods before, so I am going to discuss some of the details about variables below.