c++ code a destructor to delete the dynamically allocated array!!!
In my code I have to define a class called Array, it simulates a dynamic array of integers and I also have to code a constructor. This all seems to work fine, but I also have to code a destructor that will delete the dynamically allocated array, this is where I run into problems. This is the code that I have.
cout <<"Enter the number of integers in the array.\n\n";
pointer = new int[size];
for (i=0; i< size; i++)
cout <<"Enter interger # " << i+1 <<"\n";
}//end of load
int i =0;
cout <<"The array contains " <<size << "integers.\n\n";
cout <<"They are:\n";
while (i < size)
}//end of loop
~Array() //destructor to delete the array
void main (void)
It runs fine when I comment out the destructor, but with it in my program crashes after it displays the integers in the array. Any help would be great. Thanks