Copy Constructor crashing program
Hi All,
Need some help here with a copy constructor. I'm trying to copy a character array instance. Here's what i have so far:
Code:
listType::listType(const listType & init) // Copy constructor
{
nodeptr temp1, temp2, last;
start = NULL;
len = 0;
temp1 = init.start;
if (temp1 != NULL)
{
start = new ListNodeType;
len = 1;
start->next = start;
(start->info).key = (temp1->info).key;
last = start;
temp1 = temp1->next;
}
while (temp1 != NULL)
{
temp2 = new ListNodeType;
len++;
temp2->next = start;
last->next = temp2;
(temp2->info).key = (temp1->info).key;
last = temp2;
temp1 = temp1->next;
}
return;
}
Here's how I invoke the copy constructor:
Code:
listType list1(list);
When the copy constructor is invoked my program crashes. Don't know why.
Any help would be appreciated.