-
Diff betweeen static and local
In the below prog,node * q is local to a function add() but it acts as static .how?#includeusing namespace std;class ll{public: struct node{ int data; node *link; }*p;ll(){p=NULL;}int add(int x){ node *q,*r;if(p==NULL){ r=new node; r->data=x; r->link=NULL;q=r; p=q;}else{r=new node;r->data=x;r->link=NULL;q->link=r;q=q->link;}return 0;}void display(){ node *q; q=p;while(q!=NULL){cout
-
Plz explain following program
In the below program ,in function add() node * q is local but it acts as static ie I mean it works correctly how is it possible?#includeusing namespace std;class ll{public: struct node{ int data; node *link; }*p;ll(){p=NULL;}int add(int x){ node *q,*r;if(p==NULL){ r=new node; r->data=x; r->link=NULL;q=r; p=q;}else{r=new node;r->data=x;r->link=NULL;q->link=r;q=q->link;}return 0;}void display(){...