Wednesday, 2 October 2013

C++ and returning a reference

C++ and returning a reference

Can any one explain to me the difference between these two functions:
int& test(int a)
{
return a;
}
and
int test(int a)
{
return a;
}
and tell me what the purpose when we use '&' operator after return type of
a function? When should we use it because I've rarely seen it before.

No comments:

Post a Comment