Guest User

Untitled

a guest
Aug 17th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. Placement new to initialize inplace object
  2. class SomeClass {
  3. public:
  4. SomeClass() {}
  5.  
  6. int someInt;
  7. };
  8.  
  9. int main(...) {
  10. int dummy = 42;
  11.  
  12. int *pSomeClass = new (&dummy) SomeClass();
  13. cout << pSomeStruct->someInt << endl;
  14. }
Add Comment
Please, Sign In to add comment