Aug 29, 2018
C++ Basics
C++
std::vector::push_back()
std::vector::push_back()void push_back (const value_type& val);
void push_back (value_type&& val);// vector::push_back
#include <iostream>
#include <vector>
int main ()
{
std::vector<int> myvector;
int myint;
std::cout << "Please enter some integers (enter 0 to end):\n";
do {
std::cin >> myint;
myvector.push_back(myint);
} while (myint);
std::cout << "myvector stores " << int(myvector.size()) << " numbers.\n";
return 0;
}Last updated