December
1998 QUESTION 4 Total Marks: 20 Marks |
Click here to access other
questions
Click to access
|
(a) | You are to design a C++ program for creating and
manipulating entries in a telephone book. Consider the following class definition for a
Person entry in a telephone book. class
Person { Person() {number = 0; name = 0;} //
Constructor void display() { // Display a
person
|
|
(a) | The telephone book is an array of
10,000 Person entries and also an integer that records the number of entries in the
telephone book. Give the definition of a class Telephone_book that contains: (1) the private data items listed above and (2) a default constructor that initialises the number of entries to 0.
|
[3] |
(b) | Give the implementation of a method display that displays the details of every person
in the telephone book.
|
[3] |
(c) | Give the implementation of a method add_person that reads a last name and a telephone
number from the user, creates a new person, and adds the person to the end of the array if
there is a space.
|
[8] |
(d) | Give the implementation of a method find that takes a telephone number and displays the person with the corresponding telephone number. If the telephone number does not exist in the telephone book, give an appropriate error message. | [6] |