|
-
December 20th, 2002, 08:08 AM
#1
about return local address in function ?
Golden rule:
Never return the address of an automatic local variable from a function
Never return a reference to automatic local variable from a function
any one please me some example
int* func1(){
int* p;
int i = 20;
p = &i;
return p;
}
the example above is correct !!
why ? p is store address of i (whice i is local variable)
i understand allright or not ?
please give easy example
i am new in C++
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|