Initializing Objects with Initializer Lists - C++ STL

C++ examples for STL:vector

Description

Initializing Objects with Initializer Lists

Demo Code

#include <iostream>
#include <vector>

using namespace std;

int main()/*from  ww  w  .ja  v  a2 s  .  c o m*/
{
    using MyVector = vector<int>;

    MyVector vectorA( 1 );
    cout << vectorA.size() << " " << vectorA[0] << endl;

    MyVector vectorB( 1, 10 );
    cout << vectorB.size() << " " << vectorB[0] << endl;

    return 0;
}

Result


Related Tutorials