A function can return a reference.Returning a reference can be very useful when you are overloading certain types of operators.
However,it also can be employed to allow a function to be used on the left side of an assignment statement.
e.g.
int &f( )//return a reference int x; int main( ) { f( )=100; //assigning 100 to reference returned by f() cout<< x <<"\n"; return 0; } //return an int reference. int &f() { return x; //return a reference to x }
Liked By
Write Answer
How to return a reference in c ?
Join MindStick Community
You have need login or register for voting of answers or question.
AVADHESH PATEL
15-Jun-2013