April
1999 QUESTION 1 (Compulsory) Total Marks: 20 Marks |
Click here to access other
questions
Click to access
|
(a) | State two components of an Abstract Data Type
in object-oriented programming.
|
[2] |
(b) | Explain the difference between a class
and an object in C++.
|
[2] |
(c) | Explain the purpose of a pure virtual
function in C++. Give an example declaration of one.
|
[3] |
(d) | Consider the following program fragment: class Person { class Telephone_book {
|
|
(i) Explain what a deep copy of objects is in C++ and give an example of when it is most likely to be used. | [2] | |
(ii) Give the implementation of a deep copy
constructor for the Telephone_book
class.
|
[5] | |
(e) | Consider the following function in C++; void foo(int *y, int *z) {
|
|
(i) Trace the output of the function foo(&a, &b), assuming that int a = b =0 and the following values are input for x: 1,4,2,1,-9. | [4] | |
(ii) Explain the behaviour of foo. | [2] |