Answers for "push value in vector c++"

C++
3

how to append to a vector c++

//vector.push_back is the function. For example, if we want to add
//3 to a vector, it is just vector.push_back(3)
vector <int> vi;
vi.push_back(1); //[1]
vi.push_back(2); //[1,2]
Posted by: Guest on April-13-2020
1

java vector push_back

// push_back equivalent
ArrayList<int> a = new ArrayList<int>();
a.add(2);             // Add element to the ArrayList.
a.add(4);

// pop_back equivalent.
a.remove(a.size()-1); // Remove the last element from the ArrayList.
Posted by: Guest on February-22-2020

Browse Popular Code Answers by Language