I am looping this function to extract transaction from the list. it works fine for the first loop, but gets terminated on the second loop for deleting the list. please, help me to figure this out.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Transaction TransactionList::extract(){
if(size > 0){
--size;
}
Transaction tempT = list[0];
temp = new Transaction [300];
for (int i = 1; i <=size+1; i++){
temp[i-1] = list[i];
}
delete [] list;
list = NULL;
list = temp;
delete [] temp;
temp = NULL;
return tempT;
}
also, tempT doesn't get assigned as correct transaction on the second loop.