Created
November 30, 2018 10:46
-
-
Save allstarschh/297f881aaee0f11178899b31e3391237 to your computer and use it in GitHub Desktop.
This file contains 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
#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