void inheritanceClassDemo()
{
    ListItem *item;

    /* Lets see how the items are created. Please use step into the
     * see how the next instruction creates an element.
     */
    IntListItem intItem0(0);

    /* Now lets see it create a different type of item. Please use
     * step into the see this go to the FloatListItem constructor.
     */
    FloatListItem floatItem0(1.0);

    /* Now we will start adding items to lists. We will create one
     * list that may contain either Integers or Floats.
     */
    List    linkedList;

    /* Let's start adding to the list. Items will be added to the end
     * of the list.
     */
    linkedList.add(intItem0);
    linkedList.add(intItem1);
    linkedList.add(intItem2);
    linkedList.add(floatItem0);
    linkedList.add(floatItem1);
    linkedList.add(floatItem2);

    /* Display the contents of the linked list. Notice a mixture of integers
     * and floating numbers are inserted into the list. The "displayValue"
     * function for these items will be resolved at runtime since "item" is a
     * pointer to the base class ListItem.
     */

    for (item = linkedList.getFirst();
	 item != 0;
	 item = item->getNext())
    {
        item->displayValue();
    }

    /* Remove the items from the list.
     */
    while (linkedList.getFirst() != 0)
    {
        linkedList.remove(*(linkedList.getFirst()));
    }

    /* If you stepped into during the adds, you would have seen how
     * that the member function "add" for List was called. Now we will
     * create another list that is sorted using SortedList which
     * derives from List, but changes the add function to sort the
     * list.
     *
     * NOTE: We will be using the overridded member function "compare"
     *       in the ListItem for each of the derived classes
     *       "IntListItem" and "FloatListItem". Since these cannot be
     *       compared between each other we will create two classes;
     *       one for integers and one for floats.
     */
    SortedList  intList;
    SortedList  floatList;

    /* Add the first items. Please step into the next instructions to
     * see how the "compare" member function get called for
     * IntListItem and FloatListItem. Also notice how the "add" member
     * function get called in the SortedList Class.
     */
    intList.add(intItem1);
    floatList.add(floatItem1);

    /* Now lets add something to the front of the list.
     */
    intList.add(intItem0);
    floatList.add(floatItem0);

    /* Now to the end of the list.
     */
    intList.add(intItem3);
    floatList.add(floatItem3);

    /* Now in the middle.
     */
    intList.add(intItem2);
    floatList.add(floatItem2);

    /* Display the contents of the sorted integer linked list.
     */
    for (item = intList.getFirst();
         item != 0;
         item = item->getNext())
    {
        item->displayValue();
    }

    /* Display the contents of the sorted floating linked list.
     */
    for (item = floatList.getFirst();
         item != 0;
         item = item->getNext())
    {
        item->displayValue();
    }

}