-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.h
81 lines (61 loc) · 1.44 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// Created by decar on 6/13/2022.
//
#ifndef CPPTESTING_NODE_H
#define CPPTESTING_NODE_H
#include <string>
class TestItem {
private:
std::string message;
public:
TestItem() {
message = "testMessage";
}
TestItem(int count) {
message = "Message #" + std::to_string(count);
}
std::string get_message() {
return this->message;
}
};
class Node {
private:
TestItem *item;
Node *n;
public:
Node() {
this->item = nullptr;
this->n = nullptr;
}
Node(TestItem *item) {
this->item = item;
this->n = nullptr;
}
Node(TestItem *item, Node *next) {
this->item = item;
this->n = next;
}
TestItem get_item() {
return *item;
}
void set_item(TestItem i) {
this->item = &i;
}
Node *next() {
return this->n;
}
void set_next(Node *next) {
this->n = next;
}
Node& operator=(Node other) {
this->set_item(other.get_item());
this->set_next(other.next());
return *this;
}
Node& operator=(Node* other) {
this->set_item(other->get_item());
this->set_next(other->next());
return *this;
}
};
#endif //CPPTESTING_NODE_H