由买买提看人间百态

topics

全部话题 - 话题: intitem
(共0页)
m*********e
发帖数: 37
1
来自主题: Programming版 - A weird segmentation fault!
Attached is the implementation of the List class:
IntList.h
*****************************************************
#ifndef _INTLIST_H_
#define _INTLIST_H_
#define NULL 0
class IntItem
{
public:
IntItem()
{
//itm = -1;
nxt = NULL;
}
IntItem(int value, IntItem * n = NULL):itm(value), nxt(n){}
int itm;
IntItem *nxt;
};
class IntList
{
public:
IntItem *list;
mutable IntItem *curr;
IntList();
~IntList();
void add
m*********e
发帖数: 37
2
来自主题: Programming版 - A weird segmentation fault!
Thanks! I did bt under g++3.2, it said something wrong with concat_list();
I am testing under g++ 4.0.2. The cause it tells now is because in "="
function, I delete the ptr twice.(I don't understand why it happened!)
********************************
void IntList::operator=(IntList newList)
{
IntItem *nptr;
IntItem *ptr = list;
while (ptr)
{
nptr = ptr->nxt;
delete(ptr); //glibc detected here...
ptr = nptr;
}
(共0页)