#includeIn this example, we create a shared_ptr to an integer with value 123. We then create a weak_ptr that points to the same integer. We check if the weak_ptr is expired, and if not, we lock the weak_ptr to get a shared_ptr reference to the object and print its value. We then reset the shared_ptr to delete the integer, and finally check if the weak_ptr is expired. The std weak_ptr is part of the C++11 standard library and is included in the#include int main() { std::shared_ptr sptr = std::make_shared (123); std::weak_ptr wptr = sptr; if (!wptr.expired()) { std::cout << *wptr.lock() << std::endl; } sptr.reset(); if (wptr.expired()) { std::cout << "weak_ptr is now expired" << std::endl; } return 0; }