Displaying Objects

Let us now return to the ZoomMapZoomMap that we created earlier (§4.2) and examine what it's made of. There is a function for doing this, called astShowastShow, which is provided mainly for looking at Objects while you are debugging programs.

If you consult the description of astShow in Appendix B, you will find that it takes a pointer to an ObjectObject (of type AstObject$*$) as its argument. Although we have only a ZoomMap pointer available, this is not a problem. If you refer to the brief class hierarchy described above (§4.3), you will see that a ZoomMap is an Object, albeit a specialised one, so it inherits the properties of all Objects and can be substituted wherever an Object is required. We can therefore pass our ZoomMap pointer directly to astShow, as follows:


\begin{terminalv}
astShow( zoommap );
\end{terminalv}

The output from this will appear on the standard output stream and should look like the following:


\begin{terminalv}
Begin ZoomMap
Nin = 2
IsA Mapping
Zoom = 5
End ZoomMap
\end{terminalv}

Here, the “Begin” and “End” lines mark the beginning and end of the ZoomMap, while the values 2 and 5 are simply the values we supplied to initialise it (§4.2). These have been given simple names to make them easy to refer to.

The line in the middle which says “IsA MappingMapping” is a dividing line between the two values. It indicates that the “NinNin” value is a property shared by all Mappings, so the ZoomMap has inherited this from its parent class (Mapping). The “ZoomZoom” value, however, is specific to a ZoomMap and isn't shared by other kinds of Mappings.