C++ 23 · Classes, memory and templates

Share ownership with shared_ptr

The object is deleted when the last shared_ptr to it goes away.

auto a = std::make_shared<Account>(50.0);
auto b = a;
std::cout << a.use_count() << '\n';

Official C++ 23 documentation

More classes, memory and templates commands

All classes, memory and templates commands · C++ 23 cheatsheet

Was this page helpful?