node*connect_node(node*pthis,char ch){
node*temp = pthis->next;
pthis->next = new node(ch,pthis,temp);
cout<<"call1";
temp->prev = (pthis->next);
cout<<"call2";
return pthis->next;
}
노드는 제가 정의한 구조체이고 멤버로 char ch, node*prev, node*next 를 가지고 있습니다. 저 connect함수를 실행하면 call2가 출력되지 않고 비정상 종료됩니다. 뭐가문제인가요? 생성자에 준 인자는 각각 ch,prev,next에 저장됩니다
확인해본 결과 pthis->next가 NULL일때만 저 함수를 쓸 때 문제가 발생하는데 그렇다 해도 이해가 안되네요
학교숙제는 프갤로
백준 에디터문제긴함...
지금다시보니 NULL 이면 temp 가 null인데 temp->prev를 참조하니 문제가 될만하네