It has two member variables m range is a pointer to an


mid1-lab.dvimid1-lab.dvi

Problem (5) Consider a NumberRange class that has the following:

  • It has two member variables: m range is a pointer to an array of ints, and m size the number of elements in that array.
  • It has a single constructor that takes two integer arguments a and b, with a guar- anteed to be greater than or equal to b. The constructor sets m size to the number of integers between (and including) a and b. It then allocates an array of integers to store the values a, a+1, a+2, . . ., b, with m range pointing to the array. For example, if a is 5 and b is 9, then the constructor would allocate an array and fill it with the values 5, 6, 7, 8, 9 in that order.
  • It has a destructor that does any needed clean-up.
  • It has a member function print() that prints out the values in the array, in order, one per line. Write the C++ code for both the .h and .cpp files for this class.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: It has two member variables m range is a pointer to an
Reference No:- TGS01298598

Now Priced at $30 (50% Discount)

Recommended (96%)

Rated (4.8/5)