#include #include using std::shared_ptr; using std::weak_ptr; using std::make_shared; int main(int argc, char **argv) { weak_ptr w; { shared_ptr x; { shared_ptr y = make_shared(10); w = y; x = w.lock(); std::cout << *x << std::endl; } std::cout << *x << std::endl; } shared_ptr a = w.lock(); std::cout << a << std::endl; return 0; }