159k views
5 votes
For the bag class in Chapter 3 (using a fixed array and a typedef statement) what steps were necessary for changing from a bag of integers to a bag of double values?

A. Change the array declaration from int data[CAPACITY] to double data [CAPACITY and recompile.
B. Change the int to double in the typedef statement and recompile
C. Round each double value to an integer before putting it in the bag.
D. Round each double value to an integer after taking it out of the bag.

User Julien L
by
4.6k points

1 Answer

4 votes

Answer:

B. Change the int to double in the typedef statement and recompile

Step-by-step explanation:

A typedef declaration is used to assign names to database.

Syntax:

typedef data_type new_name;

For this case the initial deceleration was

typedef int bag;

To change it to double values we have to do following

typedef double bag;

Therefore, option B is correct change the int to double in the typedef statement and recompile.

User Ready Cent
by
4.4k points