-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathnode.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 binary tree.
//
//*****************************************************************************************************
#ifndef NODE_H
#define NODE_H
//*****************************************************************************************************
template <typename T>
struct Node {
T value;
Node<T> *left;
Node<T> *right;
Node();
Node(const T &v, Node<T> *l = nullptr, Node<T> *r = nullptr);
};
//*****************************************************************************************************
template <typename T>
Node<T>::Node() {
value = T(); // T() - default initialization (0 for numbers, empty string for strings, etc.)
left = nullptr;
right = nullptr;
}
//*****************************************************************************************************
template <typename T>
Node<T>::Node(const T &v, Node<T> *l, Node<T> *r) {
value = v;
left = l;
right = r;
}
//*****************************************************************************************************
#endif