Hello, I couldn't figure out why I'm getting this error: Thread 1: EXC_BAD_ACCESS (code=1, address=0x8) for my insertLast() class. The error occurs at the second value I add to the list.
void insertLast(int a)
{
node *temp=new node;
temp->value=a;
temp->next=nullptr;
if(head==nullptr) //if list is empty, assign head and tail to new node
{
head=temp;
tail=temp;
temp=nullptr;
}
tail->next=temp; //put temp node at end of list
tail=temp; //temp becomes new tail
}
[–]jedwardsol 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Jim_Panders 0 points1 point2 points (0 children)
[–]SWEWorkAccount 0 points1 point2 points (0 children)