Create and Delete
Explore how to construct and destroy containers in the C++ Standard Library. Understand the use of various constructors, including default, copy, move, and initializer lists, and learn how to manage container memory with clear methods. Gain insight into special cases like std::array and its unique initialization and deletion constraints.
We'll cover the following...
We'll cover the following...
You can construct each container by a multitude of constructors. To delete all elements of a container cont, you can use cont.clear(). It makes no difference if you create a container, if you delete them or if you add or remove elements. Each time the container takes care of the memory management.
The table shows you the constructors and destructors of a container. A ...