Storing a Growing Number of Objects Using STL vector - C++ STL

C++ examples for STL:vector

Description

Storing a Growing Number of Objects Using STL vector

Demo Code

#include <cinttypes>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
    vector<int32_t> stlVector{ 10, 65, 3, 2, 49 };

    for (int i = 0; i < stlVector.size(); ++i)
    {/*w  w  w  . j ava2 s  .co m*/
        std::cout << stlVector[i] << std::endl;
    }

    for (auto&& number : stlVector)
    {
        std::cout << number << endl;
    }

    return 0;
}

Result


Related Tutorials