Suggested Projects

 < Day Day Up > 



  1. Library Manager: Write a program to keep track of your books. Declare a structure called Book that contains the necessary data members to describe a book. A few of these data members might be named Title, Author, and ISBN, etc. Allow users to save and load your library information from disk. The hardest part of this project will be determining how to represent the collection of books in memory. You might choose to use an array. You could also explore some of the Standard Template Library collection classes that may make your life easier.

  2. RobotRat Structure: Convert the RobotRat project implemented in chapter 3 to use a structure to represent the RobotRat. The structure declaration for RobotRat was given as an exercise in skill building exercise 6.

  3. Computer Simulator Structure: Convert the computer simulation project from chapter 9 to use a structure to represent the computer. The computer structure might include its memory, the program counter, and the accumulator. Possible functions for the computer might include loadProgram(), runProgram(), fetch(), decode(), execute(), and store().

  4. Linked List: A special property of structures and classes in C++ is that the name of the structure or class can appear in the body of the declaration. Consider the following example:

    struct Node{    int item;    Node* previous;    Node* next; };

    Here, the struct name Node appears in the body of the Node declaration to declare two Node pointers named previous and next. This method is used to declare data structures fit for use in a linked list. Use the struct declaration above to write a linked list. This is as much an exercise in the use of pointers as it is the use of structures. Here are a few hints to get you started:

    click to expand

    The diagram above shows three Node objects inserted into a doubly linked list. There are two Node pointer variables named Head and Tail. The Head pointer is set to point to the first Node object inserted into the list. The Tail pointer should always point to the last Node object inserted into the list. The Node pointers in each Node object are set to point to the previous Node object and the next Node object as required. Examine node 1 in the diagram. The previous pointer points to Tail, which it should always point to, and the next pointer points to node 2.

    You are to write functions that let you insert and remove nodes at or from any position in the list, and functions that let you traverse the list both forward and backward.

  5. Linked List: Convert the library program described in project 1 to use a linked list data structure. After completing the project, write a brief paragraph describing why linked lists are a more efficient use of memory than an array.



 < Day Day Up > 



C++ for Artists. The Art, Philosophy, and Science of Object-Oriented Programming
C++ For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504028
EAN: 2147483647
Year: 2003
Pages: 340
Authors: Rick Miller

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net