why we create construtor in node class
what is the purpose of creating constructor in node class
Constructor in node class
it is just used to initialize value at the time of object creation, however it is not compulsory to create a constructor you can create and use getter setter functions.
Can you explain it with example
class Node{
int value;
Node* left;
Node* right
public void setValue(int x){
value = x;
}
public void setLeftNode(Node* ptr){
left = ptr;
}
public void setRightNode(Node* ptr){
right = ptr;
}
}