double free or corruption (fasttop) help
I am sure the operator= isn't overloaded correctly but how can I fix this? My friend looked at this and also helped me on the overload operators and we have identical operators to help debug. Did I type something wrong?
Code:
*** glibc detected *** queue: double free or corruption (fasttop): 0x0907e008 ***
======= Backtrace: =========
/lib/libc.so.6[0x48c268c9]
queue[0x804922b]
queue[0x8048ef5]
queue[0x8048c51]
queue[0x80489cc]
queue[0x8049714]
/lib/libc.so.6(__libc_start_main+0xf5)[0x48bca635]
queue[0x8048881]
======= Memory map: ========
08048000-0804b000 r-xp 00000000 09:03 3663402
0804b000-0804c000 rw-p 00002000 09:03 3663402
0907e000-0909f000 rw-p 00000000 00:00 0 [heap]
48b8e000-48bad000 r-xp 00000000 68:05 483370 /usr/lib/ld-2.15.so
48bad000-48bae000 r--p 0001e000 68:05 483370 /usr/lib/ld-2.15.so
48bae000-48baf000 rw-p 0001f000 68:05 483370 /usr/lib/ld-2.15.so
48bb1000-48d5c000 r-xp 00000000 68:05 483373 /usr/lib/libc-2.15.so
48d5c000-48d5d000 ---p 001ab000 68:05 483373 /usr/lib/libc-2.15.so
48d5d000-48d5f000 r--p 001ab000 68:05 483373 /usr/lib/libc-2.15.so
48d5f000-48d60000 rw-p 001ad000 68:05 483373 /usr/lib/libc-2.15.so
48d60000-48d63000 rw-p 00000000 00:00 0
48d81000-48daa000 r-xp 00000000 68:05 483865 /usr/lib/libm-2.15.so
48daa000-48dab000 r--p 00029000 68:05 483865 /usr/lib/libm-2.15.so
48dab000-48dac000 rw-p 0002a000 68:05 483865 /usr/lib/libm-2.15.so
48f41000-48f5d000 r-xp 00000000 68:05 483949 /usr/lib/libgcc_s-4.7.2-20120921.so.1
48f5d000-48f5e000 rw-p 0001b000 68:05 483949 /usr/lib/libgcc_s-4.7.2-20120921.so.1
4930f000-493ef000 r-xp 00000000 68:05 484683 /usr/lib/libstdc++.so.6.0.17
493ef000-493f3000 r--p 000e0000 68:05 484683 /usr/lib/libstdc++.so.6.0.17
493f3000-493f4000 rw-p 000e4000 68:05 484683 /usr/lib/libstdc++.so.6.0.17
493f4000-493fb000 rw-p 00000000 00:00 0
b77c3000-b77c6000 rw-p 00000000 00:00 0
b77dc000-b77e0000 rw-p 00000000 00:00 0
b77e0000-b77e1000 r-xp 00000000 00:00 0 [vdso]
bfccf000-bfcf0000 rw-p 00000000 00:00 0 [stack]
Abort
Code:
Queue :: Queue(int size)
{ size=0;
count=0;
MaxElements=256; }
Queue :: ~Queue()
{ clear(); }
Queue :: Queue(const Queue& other)
{ InitFromCopy(other); }
Queue Queue :: operator= (const Queue& other)
{
//clear();
InitFromCopy(other);
return *this;
}
bool Queue :: operator== (const Queue& other) const
{
for(int i=0; i<count; i++)
{
if(qa.get(i) != other.qa.get(i))
{ return false; }
}
return true;
}
bool Queue :: operator!= (const Queue& other) const
{
if((*this)==other)
return false;
return true;
}
ostream& operator << (ostream& s, const Queue& q)
{
s << q.front() << "\t<-- front" << endl;
for(int i=1; i<q.size(); i++)
s << q.qa.get(i) << endl;