-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProject4.h
52 lines (45 loc) · 896 Bytes
/
Project4.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
#include <iostream>
class Node {
private:
char ch;
int freq;
Node* left;
Node* right;
string code;
public:
Node();
Node(const char& c, const int& f);
void setChildren(Node* l, Node* r);
char getCharacter() { return ch; };
int getFrequency() { return freq; };
Node* getLeftCh() { return left; };
Node* getRightCh() { return right; }
string getCode() { return code; }
void setCode(string c);
Node& operator=(const Node& j);
};
Node::Node() {
freq = 0;
left = right = NULL;
}
Node::Node(const char& c, const int& f) {
ch = c;
freq = f;
left = right = NULL;
}
void Node::setChildren(Node* l, Node* r) {
left = l;
right = r;
}
void Node::setCode(string c) {
code = c + code;
}
Node& Node::operator=(const Node& j) {
if (this != &j) {
ch = j.ch;
freq = j.freq;
left = j.left;
right = j.right;
}
return *this;
}