In my program below I need to make a class that manages dynamic array of integers and
Question:
In my program below I need to make a class that manages dynamic array of integers and the SIZE is chosen by the user. The output must verify that the array can hold for example 7 integers before actually filling it with user input. Please help with where I am going wrong. Also is the usage of my constructor correct?
#include
#include
using namespace std;
class Numbers {
private:
size_t SIZE;
int *numbers;
public:
Numbers() { SIZE = 0; };
void choose_size()
{
cout << "How many numbers? >> ";
cin >> SIZE;
make_storage();
cout << "\nYou now have space for, " << sizeof(numbers) << " numbers. \n";
}
void make_storage()
{
numbers = new int[SIZE];
}
};
int main()
{
Numbers n;
n.choose_size();
}
Excellence in Business Communication
ISBN: 978-0136103769
9th edition
Authors: John V. Thill, Courtland L. Bovee