Created
June 23, 2011 05:20
-
-
Save tuananh/1041948 to your computer and use it in GitHub Desktop.
c++ memory management
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int * foo() | |
{ | |
int a = 5; | |
return &a; | |
} | |
using std::cout; | |
int main() | |
{ | |
int* p = foo(); | |
cout << *p; | |
*p = 8; | |
cout << *p; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment