August 2000 QUESTION 4 Total Marks: 15 Marks |
Click here to access other
questions
SUGGESTED SOLUTIONS |
A sales manager requires a program to maintain details of his customers. He wishes to split his customers up into four categories, depending on their location, which can be one of Singapore, India, Malaysia or China. In addition to this, for each customer, he wishes to store their name, which is a string, the customers average expenditure, in Singapore Dollars, which is an integer, and a transaction record, which is an array of objects of type Transaction. (a) Define a suitable enumerated type,
called Location, which can take on any of the values of location given
above. [1 mark] (b) Define a class, called Customer,
which can be used to store all of the customers details given
above. [5 marks] (c) Add to your class an inline method,
called GetName which returns a copy of a customers name. [3
marks] (d) Briefly explain what is special
about an inline method in C++, and give an example of where it may
be useful to declare a method inline. [2 marks] (e) Implement a constructor for the
Customer class, such that it takes as parameters the customers
location, the customers name, the customers average expenditure
and the customers Transaction record, and initialises them appropriately.
[4 marks] |