20,741
edits
mNo edit summary |
|||
| Line 272: | Line 272: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Now, given that | Once we start using a hash as a template for other hashes using the "parents" vector, we are actually creating a class that is copied to each new hash. This new copy of the class is called an "object" after creation. | ||
A "class" is really just a template for a certain data type that consists of other data types and provides functions to work with the class. The functions publicly accessible are called its "interface" because these functions are meant to be used by the users of your class. This is in contrast to member fields which are usually not meant to be accessed directly. | |||
Once a class is used as a template to create a new object, we say the class is getting "instantiated", i.e. an instance of the class (an actual object) is created. This makes it then possible to actually make use of its interface and access member functions (which are methods). Also see [http://flightgear.org/forums/viewtopic.php?f=30&t=14737#p145769]. | |||
Now, given that the creation of new hashes using a template class is such a common thing to do - we could just as well add a new function to the parent hash that we can use to construct new hashes. As you could see already, the fields (or members) of a hash are specified in a well-defined form: "field_name:value". | |||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
| Line 287: | Line 294: | ||
This isn't any different for fields that are of type "function": | This isn't any different for fields that are of type "function": | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||