Yi Chai
2003-11-30 00:41:48 UTC
I have decided to do more testing when I was really bored this afternoon,
and something really strange happened with my destructor.
I put in tester.body the following
q.Enqueue('a');
q.Enqueue('b');
q2.Enqueue('c');
q2.Enqueue('d');
q2.Enqueue('e');
q2 = q;
*q3 = q2;
delete &q;
delete q3;
delete &q2; <<<<<<<<<
now, if I comment out the line pointed to by <<<<<<, then the program works
fine.
I have put in some cout functions that prints hello in my destructors to
test it.
If I comment out that last line, hello is output 3 times, which is correct,
because i manually deleted q and q3 and also when program ends, memory
deleted q2.
but if I have that last line in there, trying to manually delete q2, a
segmentation fault occurs right after 3 lines of hello are output.
anyone see anything potentially wrong with this? My program worked fine
before this.
and something really strange happened with my destructor.
I put in tester.body the following
q.Enqueue('a');
q.Enqueue('b');
q2.Enqueue('c');
q2.Enqueue('d');
q2.Enqueue('e');
q2 = q;
*q3 = q2;
delete &q;
delete q3;
delete &q2; <<<<<<<<<
now, if I comment out the line pointed to by <<<<<<, then the program works
fine.
I have put in some cout functions that prints hello in my destructors to
test it.
If I comment out that last line, hello is output 3 times, which is correct,
because i manually deleted q and q3 and also when program ends, memory
deleted q2.
but if I have that last line in there, trying to manually delete q2, a
segmentation fault occurs right after 3 lines of hello are output.
anyone see anything potentially wrong with this? My program worked fine
before this.