Skip to content

Commit 0bf48a0

Browse files
Creating a Dynamic Node
1 parent 34b90f5 commit 0bf48a0

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

dynamic_node.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,24 @@ class Node
99
Node(int val)
1010
{
1111
this->val = val;
12+
this->next = NULL;
1213
}
1314
};
1415

1516
int main()
1617
{
18+
/* Static Node */
19+
// Node head(10);
20+
21+
/* Dynamic Node */
1722
Node *head = new Node(10);
1823
Node *a = new Node(20);
24+
head->next = a;
25+
26+
cout << head->val << endl;
27+
cout << a->val << endl;
28+
cout << head->next->val << endl;
29+
cout << (*(*head).next).val << endl;
1930

2031
return 0;
2132
}

dynamic_node.exe

50.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)