••• Unprocessable paragraph: \start
Home Segments Index Top Previous Next

725: Mainline

\slidefont

One alternative is to include a pointer to a railroad car in the definition of the railroad_car class itself. To create a train, you simply arrange for each railroad_car object in the train, except for the final one, to carry a pointer to the next railroad car. The last railroad_car object carries a pointer to 0, also known as the null pointer.

••• Unprocessable paragraph: The following, for example, illustrates how you would arrange the pointers in a three-car train list: \begincode Three railroad_car objects, with pointers inside: \par C:\Phw\Onto\CPP\lists.tex •••

*——-* *——-* *——-* | | *-> | | *-> | | |——-| | |——-| | |——-| | | | | | | | | |——-| | |——-| | |——-| | | –* | | –* | 0 | <– null pointer |——-| |——-| |——-| | | | | | |

Such pointers are called internal pointers, because they are stored inside the class objects whose primary purpose is to describe domain-specific individuals. C:\Phw\Onto\CPP\lists.tex •••