CS 202 Fall 2013 > In-Class Challenge for Thursday, September 26, 2013 |
CS 202 Fall 2013
In-Class Challenge for Thursday, September 26, 2013
Note: There is no test program for today’s challenge.
What to Do
Do as many of the following as you can before class ends. After each, please show me your work.
- Write a program that does the following:
- Ask the user for an array size.
- Dynamically allocate an
int
array of that size. - Fill the array with some kind of data.
- Print the data from the array.
delete
the array.
- Modify the above so that
the array functionality is in a class.
The class should have three member functions:
- A constructor taking an
int
, which it uses as the array size. It dynamically allocates the array, storing a pointer to the array in a member variable. Then it fills the array with data. - A destructor that
delete
s the array. - A function
print
that prints the data in the array.
The program you end up with should use this class and do the same thing as the program in part 1 did.
- A constructor taking an
CS 202 Fall 2013: In-Class Challenge for Thursday, September 26, 2013 /
Updated: 26 Sep 2013 /
Glenn G. Chappell