I'm still no expert in coding but the first error I see is that you put (line 45)
ptr = new node;
where there isn't any default constructor for node. You could put
prt = new node(&value);
instead if you want to stick with the constructor you've defined. Also, there seems to be attempts to directly access the node members:
1 2
|
ptr->node_num=value;
ptr->put_next=NULL;
|
In this case you should use the public member functions defined.
in stack::pop()
it seems you're trying to dereference a null pointer.
When using a linked list, you want the class (in this case stack) containing the node struct/class to have a pointer to the first node in the list, because there is no way to access the nodes behind, only the next nodes.
Then when adding something to a linked list, you allocate new memory at node* next. There would be another node* next that would hold the next element in the list.
Hopefully this sketch would help a bit on the understanding!
Node
****
-Node* next---->Node
-void* info ****
-Node* next---->Node
-void* info ****
-Node* next
-void* info |