|
-
December 18th, 2009, 12:20 PM
#2
Re: acces local variable
My first question would be why?
Why don't you just put the local variable, a1 in your example, and put it as a member of the class?
The problem that you're having is that the variable you want is being allocated on function entry and being removed on exit. Even if you save the address of the variable it will be memory garbage after the function has exited.
Since it seems that your example is in procedural C, the best way to get your example to work would be to make "akses_a1" and regular int and call A() either before B() in main, or in B() before the cout.
I hope that helps.
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
|