![]() |
Returning address in a function
I am trying to return the address of a local variable but i can't.
my code : Code:
#include<iostream> |
Re: Returning address in a function
don't u think ur code is broken...
Code:
int A[3];and that too using Code:
int &Code:
int & |
Re: Returning address in a function
ya he is right you should take a pointer to integer instead of reference
|
Re: Returning address in a function
Quote:
First your code will not work at all except returning local address as per told by technosavvy. Just correct it. Now you should never return address of local variable. When you are calling function stack frame will create. when it's runninf the line 'return' then all local variables will be deleted. Just think if you are returning the address of local variables which is already deleted. |
| All times are GMT +5.5. The time now is 20:09. |