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 |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India