C++ 23 · Classes, memory and templates

Own an object with unique_ptr

Allocate an object that is deleted automatically when the pointer goes out of scope. Avoid raw new and delete.

auto p = std::make_unique<Account>(100.0);
std::cout << p->balance() << '\n';

Official C++ 23 documentation

More classes, memory and templates commands

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

Was this page helpful?