-
Notifications
You must be signed in to change notification settings - Fork 28
/
node.h
42 lines (32 loc) · 1.21 KB
/
node.h
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//*****************************************************************************************************
//
// This header file defines a struct template that represents a node in a doubly linked list.
//
//*****************************************************************************************************
#ifndef NODE_H
#define NODE_H
//*****************************************************************************************************
template <typename T>
struct Node {
T data;
Node<T> *next;
Node<T> *prev;
Node();
Node(const T &d, Node<T> *n = nullptr, Node<T> *p = nullptr);
};
//*****************************************************************************************************
template <typename T>
Node<T>::Node() {
data = T(); // T() - default initialization (0 for numbers, empty string for strings, etc.)
next = nullptr;
prev = nullptr;
}
//*****************************************************************************************************
template <typename T>
Node<T>::Node(const T &d, Node<T> *n, Node<T> *p) {
data = d;
next = n;
prev = p;
}
//*****************************************************************************************************
#endif