August
1999 QUESTION 1 (Compulsory) Total Marks: 20 Marks |
Click here to access other
questions
SUGGESTED SOLUTIONS |
(a) | (i) Describe one
advantage of using the object oriented approach to programming. (ii) Describe one disadvantage of using the object oriented approach to programming. |
[2] [2] |
(i)
|
||
(ii)
|
||
(b) | (i)
Explain the reasons for dividing classes into public and private areas. (ii) Define a class called Triangle, which contains three private member integer variables, called side_a, side_b and side_c, which represents the sides of the triangle. Your class should also contain a default constructor and a default destructor. (iii) Assume your Triangle class contains another constructor function, which instead takes three parameters. Give the O-O name for this situation.
|
[3] [3] [1] |
(i) The
distinction provides data hiding
|
||
(ii) A
sample definition of triangle follows: class Triangle { ~Traingle ( ); private:
|
||
(iii) Functions overloading or overloading
|
||
(c) | (i) Explain the differences
between passing arguments to a function by value and by reference. (ii) Write a function which takes an array of characters and an integer specifying the length of the array, and reverses the order of characters in the array.
|
[7] |
(i)
|
|
|
(ii) A
sample definition of reverse follows: void reverse (char a[ ], int n) {
|