Class

From REALbasicWiki

Jump to: navigation, search
Overall article skill Skill ranges from beginner (green) to expert (red)

A class is simply the generic description of an object.


[edit] Example 1

Any vehicle you can see is a unique object. But they all have features in common that can be used to group them together into a more general class, and at the same time distinguish them from other classes.

So the car you are driving might be a Volkswagen Beetle with the registration number "RB - VW 1", which belongs to the distinctive class "Volkswagen Beetle" (which is different from the classes "Mercedes" or "Jaguar"), which belongs to the class "cars" (which is different from the classes "lorries", "busses", "bikes"), which belongs to the class "vehicles".

This example demonstrates that classes are usually hierarchical, and that the actual classification is often arbitrary ("cars" for example could be sub-classed into "sport cars", "station wagons", "SUVs", etc.) and tailored to the specific needs.


[edit] Example 2

A source of confusion to beginners is that the term "objects" in everyday life refers to inanimate objects like cars, while animals or people are thought of as subjects. In programming terms though there is no difference.

You might have two cats called "Tom" and "Buster". If someone asks you what a cat is then you might say that cats are mammals, have four legs, fur, etc.

That description applies to any cat you could name (from a house cat to a Tiger) and is therefore a generic description. In programming terms "Cats" is therefore a class, while a specific cat you have in mind like "Tom" and "Buster" are objects.

[edit] See also

Personal tools
related