Consider the following list:
[LinkNode * head — LinkNode * node1 — LinkNode * node2]
I’m creating a stack of FIFO.
I Call pop() which I want to pop node1.
LinkNode::LinkNode(int numIn) {
this->numIn = numIn;
next = null;
}
.
.
.
int LinkNode::pop() {
Link * temp = head->next;
head = temp->next;
int popped = head->nodeNum;
delete temp;
Return numOut;
Question:
1) head should be a pointer or a LinkNode *?
2) Link * temp is created on the call stack and when pop finishes doesn’t temp delete automatically?
3) My major confusion is on what is the value of temp->next? Does this point to node1.next which equals node2?
Appreciate your help?
My reference is C++ for Java Programmers by Weiss.
LinkNode *is a pointer. So I’m not sure what you are asking.new) you need to free it (calldelete)