Elements can be inserted into a vector using the pushback function of C STL. Below example demonstrates the insertion operation in a vector of vectors. The code creates a 2D vector by using the pushback function and then displays the matrix. Dec 21, 2014 This feature is not available right now. Please try again later.
Description
The C++ function std::vector::push_back() inserts new element at the end of vector and increases size of vector by one.
Declaration
Following is the declaration for std::vector::push_back() function form std::vector header.
C++98C++11Parameters
None
Return valueC++ Vector Tutorial
None.
Exceptions
This member function never throws exception.
Time complexity
Constant i.e. O(1)
Example
The following example shows the usage of std::vector::push_back() function.
C++ Vector In A Vector
Let us compile and run the above program, this will produce the following result −
vector.htm
Comments are closed.
|
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |