-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.h
52 lines (40 loc) · 985 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
#ifndef NODE_H
#define NODE_H
#include<string>
using namespace std;
enum node_type{EXPRESSION, VARIABLE, INTEGER};
enum operator_type{PLUS, MINUS, MULT, DIVIDE};
union data_type {
operator_type op;
char var;
int val;
};
class Node {
public:
// Constructor
Node(char var);
Node(operator_type op = PLUS, Node* operand1 = NULL, Node* operand2 = NULL);
Node(int val);
// Destructor
~Node();
string int_to_string() const;
char print_operator() const;
Node* getLeft();
Node* getRight();
void setDataOP(operator_type opd);
void setDataVAR(char var);
void setDataVAL(int val);
void setLeft(Node* d);
void setRight(Node* d);
void setNodeType(node_type z);
node_type getNodeType();
data_type getData();
int getDataVAL();
char getDataVAR();
private:
node_type node_t;
data_type data;
Node* operand1;
Node* operand2;
};
#endif