You should debug your code by yourself.
void stack::push(int *dat)
{
ch::LinkList* newNode = new ch::LinkList;
newNode->initialize(dat,ptr);
ptr->head = newNode;
}
void stack::ch::LinkList::initialize(int *dat, ch *nxt){
data = dat;
if(nxt->head)
next = nxt->head;
else
next = 0;
}
Note that: ptr
is nullptr
,so nxt
is a nullptr
too.
So you crash…
make ptr
not null, and fix your pop function bugs, that will ok.
8
solved How to initialize nested structures in C++