I didn’t get the use of constructor node while making class of node.
Please explain
class node{
public:
int d;
node*next;
node(int d){
d=data;
next=NULL;
}
}
I didn’t get the use of constructor node while making class of node.
Please explain
class node{
public:
int d;
node*next;
node(int d){
d=data;
next=NULL;
}
}
constructor is called at the time of object declaration
when you write
node* n = new node(d);
a node n is created with data = d
and next pointer is set to null
this is use of constructor
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.