The C ++ vector container empty

  c ++ STL library comes inside a container vetcor, comes clear method --clear (). Clear but after use, and not clearing the data, the data before it is uncovered again will not change, only the clear personal guess move the pointer to the starting position, it is necessary to clear empty value, the method requires complex on resize, resize after redistribution can be directly [] access.

   reszie have been overloaded once, implemented in two ways:

    1、void resize(std::size_t __new_size, int __x);

    2、void resize(std::size_t __new_size);

  Extra x is generated after initialization think the number (in fact, personal feeling prototype gcc in the function declaration should be of a resize this void ( std :: size_t __new_size, __X int = 0);  Mo x 0)

Of course, it can also be emptied by a circulating manner. (Currently only think of these)

   If you wish to erase the two-dimensional vetcor, it would have to clear and resize line by line.

Easy to learn, gentlemen encourage each other!

Guess you like

Origin www.cnblogs.com/daker-code/p/12008620.html