In the homework you are required to use some functions that provide a certain interface. In this lab, you will be defining a function that provides a specific interface.
Write a function called identify, that provides the
following interface:
void identify(/* in */ int number, /* out */ int& type)The function must set
type to the value 0-4, as specified below.
| If the number is | Set type to | |
| 1,2,5,9 | 1 | Note: Normally we would perform such an operation with a function that takes a single in parameter and returns a value for the type. You have to do it this way for this lab, because learning to use reference parameters is part of the exercise. |
| 4,11,13,16 | 2 | |
| 3,6,7,14 | 3 | |
| 8,10,12,15 | 4 | |
| anything else | 0 |
A file lab4-main.o has been provided in the directory
~cs102/public_html You must implement your function
(with precisely the interface described above) and link it with this
object file, which includes a main that calls your function. For example, if your
implementation of identify is in the file lab4.C,
you would type:
% g++ lab4-main.o lab4.CTo compile your program. The main program provided will, provided your function works, prompt you for numbers and, after you enter a 0, will output how many of each of the types were entered.