GeekInterview.com
Series: Subject: Topic:
Question: 10 of 69

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();
}

Asked by: jayanthnasika | Member Since Aug-2010 | Asked on: Oct 13th, 2010

View all questions by jayanthnasika

This Question is not yet answered!

Related Open Questions

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.