Skip to content

Instantly share code, notes, and snippets.

@allstarschh
Created November 30, 2018 10:46
Show Gist options
  • Save allstarschh/297f881aaee0f11178899b31e3391237 to your computer and use it in GitHub Desktop.
Save allstarschh/297f881aaee0f11178899b31e3391237 to your computer and use it in GitHub Desktop.
#include <iostream>
int* foo()
{
int a;
return new (&a)int(5);
}
int* bar()
{
return new int(5);
}
int main()
{
int *b = foo();
int *c = bar();
std::cout<<"*b="<<*b<<" *c="<<*c<<std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment