1// First include the vector library:
2#include <vector>
3
4// The syntax to create a vector looks like this:
5std::vector<type> name;
6
7// We can create & initialize "lol" vector with specific values:
8std::vector<double> lol = {66.666, -420.69};
9
10// it would look like this: 66.666 | -420.69
1
2vector<int> vec;
3//Creates an empty (size 0) vector
4
5
6vector<int> vec(4);
7//Creates a vector with 4 elements.
8
9/*Each element is initialised to zero.
10If this were a vector of strings, each
11string would be empty. */
12
13vector<int> vec(4, 42);
14
15/*Creates a vector with 4 elements.
16Each element is initialised to 42. */
17
18
19vector<int> vec(4, 42);
20vector<int> vec2(vec);
21
22/*The second line creates a new vector, copying each element from the
23vec into vec2. */