test pointer

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <stdlib.h>
struct qnode {
int value;
qnode* next;
};
void insertNode(qnode*& ntop, int nvalue) {
qnode* newNode = new qnode;
newNode->value = nvalue;
if(ntop == NULL) {
ntop = newNode;
} else {
newNode->next = ntop;
ntop = newNode;
}
delete newNode;
}
int main() {
qnode* mqueue = new qnode;
mqueue->value = 12;
insertNode(mqueue, 23);
delete mqueue;
return 0;
}