Hi all,
I am trying to solve a problem found on a book slides(Problem solving with C++,Walter Savitch) and i got some problems.
I am supposed to do my own the push function for the stack, so i create a new ptr,
void Stack:ush(char the_symbol)
{StackFramePtr temp_ptr = new StackFrame;
temp_ptr->data=the_symbol;
and then i try to point the link from the head to the new node
top->link=temp_ptr;
and i get this error
Segmentation fault (core dumped)
Apart that I dont know what this error means, even though i search for it on the net, i dont see why this command top->link=temp_ptr; would cause that!
Top is declared on the header file as
StackFramePtr top;
There is this function
Stack::Stack():top(NULL)
{
//Body intentionally empty
}
would i have to initialize the top pointer here? The problem is that this function is not called by anyone else on the main program that was predone for me.
I guess i could initialise it if the stack is empty and never again.
Thanks in advance
Ilias
I am trying to solve a problem found on a book slides(Problem solving with C++,Walter Savitch) and i got some problems.
I am supposed to do my own the push function for the stack, so i create a new ptr,
void Stack:ush(char the_symbol)
{StackFramePtr temp_ptr = new StackFrame;
temp_ptr->data=the_symbol;
and then i try to point the link from the head to the new node
top->link=temp_ptr;
and i get this error
Segmentation fault (core dumped)
Apart that I dont know what this error means, even though i search for it on the net, i dont see why this command top->link=temp_ptr; would cause that!
Top is declared on the header file as
StackFramePtr top;
There is this function
Stack::Stack():top(NULL)
{
//Body intentionally empty
}
would i have to initialize the top pointer here? The problem is that this function is not called by anyone else on the main program that was predone for me.
I guess i could initialise it if the stack is empty and never again.
Thanks in advance
Ilias