C++ Vector resize()It modifies the size of the vector to the specified value ![]() Size changed to 4 and new value is SyntaxConsider a vector v. Syntax would be: Parametern : It is the new vector size. val : If n is greater than the current vector size, then value(val) is inserted in the added space. Return valueIt does not return any value. Example 1Let's see a simple example when n is less than the current vector size. Output: Initial elements are: 1 2 3 4 5 6 7 8 9 10 After resizing its size to 5, elementsare: 1 2 3 4 5 Example 2Let's see a simple example n is greater than the current vector size. Output: Elements of v1 are :java C C++ java C C++ .Net .Net
Next TopicC++ Vector
|
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week