I am getting an access violation when I try to delete the temp object. It only get the error on the third iteration of the outermost loop. I don't understand why I am getting the error because the object is declared at the beginning of the loop and destroyed at the end. Any ideas where the problem could be? Another thing, the problem compiles and runs fine with g++ but not with borland c++.

Code:HugeInt HugeInt::operator*( const HugeInt &op2 ) { HugeInt temp2; int carry = 0; int result = 0; int zeroCount = 0; for( int i = 29; i >= 0; i-- ){ HugeInt *temp = new HugeInt; // Insert appropriate number of zeroes for( int a = zeroCount; a > 0; a-- ){ (*temp).integer[30 - a] = 0; } for( int x = 29; x >= 0; x-- ){ result = integer[x] * op2.integer[i]; if( result > 10 ){ (*temp).integer[x - zeroCount] = carry + ( result % 10 ); carry = 1; } else { (*temp).integer[x - zeroCount] = carry + result; carry = 0; } } temp2 = temp2 + *temp; delete temp; zeroCount++; } return temp2; }