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

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();

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

In your code there are a few issues that need to be addressed Heres the corrected version include io... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!