Prev | Current Page 215 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

Figuratively speaking, a class is to an object as a
bridge is to the Golden Gate. A construction must satisfy some requirements to fit the bridge definition:
It must span a divide and have at least two access points; what differentiate the bridges are
characteristics like the materials and their locations. The same applies in code where an object must
satisfy the requirements of the class to be its instance and can have distinguishing characteristics.
The base syntax to declare a class is depicted in Figure 5 - 1 .
class ClassName extends SuperClass, implements Interface
{
//...
}
the class declaration can optionally
extend another class type ...
... and implement zero or more
interfaces
extends and multiple
implements are
comma separated
class body goes
between curly
brackets
Figure 5 - 1
The class keyword denotes the declaration of a class. More than one class can be declared in a single file.
Classes that are not prefixed with access modifier private are considered public and are accessible
anywhere as long as they are imported correctly, as it is explained in the next chapter.


Pages:
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227