C++20 sections · 1024 units
Open in Course

Lessons from Flexible Array

summary

You learned that dynamic allocation gives flexibility but demands responsibility. Every new needs a delete. In modern C++, smart pointers (unique_ptr, shared_ptr) handle this automatically, but understanding raw pointers teaches you what's happening underneath.

Memory leaks don't crash immediately but slowly consume resources.

Setting pointers to nullptr after delete prevents use-after-free bugs.