Skip to content

Instantly share code, notes, and snippets.

@tuananh
Created June 23, 2011 05:20
Show Gist options
  • Save tuananh/1041948 to your computer and use it in GitHub Desktop.
Save tuananh/1041948 to your computer and use it in GitHub Desktop.
c++ memory management
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