DarkSoldier
Gawd
- Joined
- Jul 8, 2001
- Messages
- 610
I have a function say,
Which compiles in VC++ without any trouble. Now suppose I have this instead,
Which gives me "warning C4172: returning address of local variable or temporary", but aren't I returning the address of a local variable in both cases? Does anybody have any idea what's so different about the second case that it warrents the warning from the compiler?
Thanks.
Code:
int* dosomething()
{
int number, *pointer ;
pointer = &number ;
return pointer ;
}
Which compiles in VC++ without any trouble. Now suppose I have this instead,
Code:
int* dosomething()
{
int number ;
return &number ;
}
Which gives me "warning C4172: returning address of local variable or temporary", but aren't I returning the address of a local variable in both cases? Does anybody have any idea what's so different about the second case that it warrents the warning from the compiler?
Thanks.