Thank you for your reply.
Firstly, temp_array probably shouldn't be a member of the class, since it will be only used locally in a few functions.
I figured that it would be better to have it locally declared rather than declaring it on the heap every time.
Code:
Secondly the name Pop suggests removing the last element, which should trivially mean decrementing the logical_size (unless you really want to shrink the array). What you really have there is what (one version of) vector::erase does
I now realize that looking back at previous code I've used (OpenGL).
Please correct me if I'm wrong, or confused, but I thought what I was doing in that section is.
Code:
// Copy dynamic_array to temp_array
for( unsigned int i = 0; i <= logical_size; i++)
{
temp_array[i] = dynamic_array[i];
}
current_size /= 2; // change the current size
delete[] dynamic_array; // delete current memory of dynamic_array
dynamic_array = new Elem [ current_size ]; // allocate new memory to dynamic_array
dynamic_array = temp_array; // copy temp_array to dynamic_array
delete[] temp_array; // delete temp_array
Again thanks for your help,
cs_student