Diff betweeen static and local

In the below prog,node * q is local to a function add() but it acts as static .how?


#include
using 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<data<<"t";
q=q->link;
}
cout<}



};

int main()
{
ll l;
l.add(3);
l.add(5);
l.add(4);
l.add(6);
l.add(7);
l.display();
}

Questions by jayanthnasika

 

This Question is not yet answered!

 
 

Related Answered Questions

 

Related Open Questions