C++ Vector emplace()
This function inserts a new element just before the position pos and size of the vector container increases.
Consider a vector 'v'. Syntax would be:
pos: It defines the position before which the new element is to be inserted.
args: Arguments forwarded to construct the new element.
It returns an iterator to the newly inserted element.
Let's see a simple example.
Elements of vector v are :1 2 3 4 5 After adding two elements, elements are :1 2 9 8 3 4 5
In this example, size of the vector container increases using emplace() function.
Let's see a simpleanother example.
Mango apple strawberry banana
In this example, the size of the vector container increases by adding new string into the vector using emplace() function.
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