I am working with C++ vectors that I faced with the following snippets code :
#include <iostream>
#include <vector>
using namespace std;
int main()
{
using MyVector = vector<int>;
MyVector vectorA(1);
cout << vectorA.size() << " " << vectorA[0] << endl;
MyVector vectorB(1, 10);
cout << vectorB.size() << " " << vectorB[0] << endl;
MyVector vectorC{ 1, 10 , 100, 1000 };
cout << vectorC.size() << " " << vectorC[3] << endl;
return 0;
}
Why in this code vector object defined with using keyword? I can't understand why vector used in this code with this approach.