Search⌘ K

Create and Delete

Explore how to construct and delete containers in C++ using different constructors and methods like clear. Understand memory management handled by containers such as std::vector and the special characteristics of std::array.

We'll cover the following...

We can construct each container using a multitude of constructors. To delete all elements of a container cont, use cont.clear(). It makes no difference if you create and delete a container or if we add and remove elements. Each time the container takes care of memory management.

The table shows the constructors and destructors of a container. All these functions can be used with ...