-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.h
62 lines (52 loc) · 898 Bytes
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef NODE_H_
#define NODE_H_
template <class T>
class Node {
private:
Node<T>* left;
Node<T>* right;
T data;
public:
Node(T data);
T getData() const;
void setData(T data);
Node<T>*& getLeft();
void setLeft(Node<T>* left);
Node<T>*& getRight();
void setRight(Node<T>* right);
virtual ~Node();
};
template<class T>
Node<T>::Node(T data){
right = nullptr;
left = nullptr;
this->data = data;
}
template <class T>
T Node<T>::getData() const {
return data;
}
template <class T>
void Node<T>::setData(T data) {
this->data = data;
}
template <class T>
Node<T>*& Node<T>::getLeft() {
return left;
}
template <class T>
void Node<T>::setLeft(Node<T>* left) {
this->left = left;
}
template <class T>
Node<T>*& Node<T>::getRight() {
return right;
}
template <class T>
void Node<T>::setRight(Node<T>* right) {
this->right = right;
}
template <class T>
Node<T>::~Node(){
}
#endif