December
1999 QUESTION 4 Total Marks: 15 Marks |
Click here to access other
questions
Click to access |
A confectionery shop requires a system to maintain details of products which it vends.You are to implement such a system.
|
||||||||||||||||||||||||||||||||
(a) |
Identify the difference between private and protected members of a class.
|
[2]
|
||||||||||||||||||||||||||||||
(b) |
An item of confectionery contains a calorie count (an integer)and a name (a pointer to an array of characters). Declare the class Confectionery that contains: •These private data items;
|
[3]
|
||||||||||||||||||||||||||||||
(c) |
Minstrels are a type of confectionery that have a calorie count of 100,and an integer value specifying the number of minstrels in a packet.Using inheritance,declare a class Minstrels ,which contains a constructor which takes a number of Minstrels and initialises all of its variables appropriately.
|
[5]
|
||||||||||||||||||||||||||||||
(d) |
A SelectionBox is a collection of di .erent types of Confectionery .Consider the following de .nition of the class SelectionBox :
Write a function,called TotalCalories ,the signature of which is
given below,which takes a reference to a SelectionBox object and returns
the sum of all the Calories which are contained within that SelectionBox
. |
[5]
|