Sunday, 8 September 2013

return statement not returning values

return statement not returning values

emp* emp::check(string a,emp* ceo)
{
emp* l;
employee* b;
l=ceo;
if(l->name==a)
{
cout<<l->name;
return l;
}
b=l->j;
while (b!=NULL)
{
check(a,b->junior);
b=b->next;
}
}
void main()
{
l = check(d,ceo);
cout<<l->name;
}
now initially the value of l->name is being printed but finally in main
value of l is not being returned. this means that it is reaching the
return statement but l is not being returned.can someone explain why?

No comments:

Post a Comment