Am I correct in saying that the relationship between Class and Object is the same as the relationship between a glass jar that you store things in? (Example: A glass jar(Class) that contains various berries(Objects))
Luzie Blankenship wrote:a glass jar and the things you store in it? (Example: A glass jar(Class) that contains various berries(Objects))
By your analogy, it would be the same as an egg carton (class) and eggs (objects).
I can kind of see why you might think that given the way some classes are written but the analogy is not apropos.
The cutter:cookies and template:object analogies are better fits. Another is that of blueprint to product. A class is like engineering drawings and specifications for building a car. Objects, of course, are the actual cars you build out of the plans. Another example: A class is like a floor plan for an apartment unit. Objects are the actual apartment units that are built based on the plan.
Junilu Lacar wrote:. . . blueprint . . . for building a car. . . .
Which tells you things like where the engine goes, but omits information like colour of bodywork or chassis number. A class Car might have spaces in for colour or number, but wouldn't specify them directly.
Even less would the blueprints have such info as speed travelled, but that is an important feature of a car. But the class would have a space for speed.
Post by:autobot
Liar, liar, pants on fire! refreshing plug:
a bit of art, as a gift, that will fit in a stocking