For this project I have a test file to test my program..it is such a long code so I will just post where I get trouble!!
1 2 3 4 5 6 7 8 9 10
int test5( )
{
sequence original; // A sequence that we'll copy.
double items[2*original.DEFAULT_CAPACITY];
size_t i;
.
.
.
}
I have tried to debug it and I found that the problem was when the program try to allocate dynamic memory for
sequence original;
in the implementation file!! I have no idea why this keep having error. This test code is fifth test, which means that there were four other test codes before this!!
All tests passed before this. I debugged this test code and found when the constructor tried to allocate memory it gives me error!!
Anyone have comment on this??
thanks
I have tried to debug it and I found that the problem was when the program try to allocate dynamic memory for sequence original;
in the implementation file!!
How did you find the problem was that statement?
I debugged this test code and found when the constructor tried to allocate memory it gives me error!!
reply to cire!!
I am using eclipse to write code and it has the debug feature!! I used it!
and the program keep crashed at test 5 so I made a break point there and see what happened..and I noticed that the program stops and gives me error massage that say
[New Thread 4448.0x1080]
warning: HEAP[sequence.exe]:
warning: Heap block at 00A41CC0 modified at 00A41DB8 past requested size of f0
after test 4 when the destructor deletes the object.
For TheIdeasMan!!
The name space is not mine!!! I thought that name main_savitch is too long but this is what I got from the text book..!!
after test 4 when the destructor deletes the object.
So it's very likely that the problem occurs in test 4 and not test 5, since the line in test 5 that you fingered doesn't actually modify any memory on the heap.
After looking over your code, I suspect it's related to current_index as the invariant that makes it's use possible (it should always be less than or equal to used) is not guaranteed. It is not updated in operator=.