Hello, I am creating a class that has a private array on the heap with a constructor that takes the size of the array and initializes it on the heap. Later I have to make a deconstructor delete the space and print out free after.
In my code, I was able to heap a private array and make a deconstructor, but I don't know how to take the size of the array and initialize it on the heap.
My guess is this:
int* size = new int();
Also when you initialize size on the heap, don't you also have to delete it too? If so, where, in the code, do you do that?
int* array = newint[size];
Student(); // Constructor
~Student(); // Deconstructor
// How do you make a constructor that takes the size of the array and initializes it on the heap
cout << "Free!" << endl;