Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <unistd.h>
- #include <memory>
- #include <stdlib.h>
- struct X {
- X() { s1.reset(new char[32]); }
- ~X() { printf("dtor\n"); }
- void DoNothing() { printf("Hello\n"); }
- void AcquireS2() { s2.reset(new char[64]); }
- std::unique_ptr<char[]> s1;
- std::unique_ptr<char[]> s2;
- };
- X* obj;
- int main() {
- obj = new X();
- obj->AcquireS2();
- obj->DoNothing();
- printf("ptr: %p %p\n", obj->s1.get(), obj->s2.get());
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment