mirror of
https://github.com/chubin/cheat.sheets
synced 2024-11-19 03:25:44 +00:00
907c3cad09
Recursively.
11 lines
559 B
Plaintext
11 lines
559 B
Plaintext
// Vectors are sequence containers representing arrays that can change in size.
|
|
|
|
// Library to include
|
|
#include <vector>
|
|
|
|
vector<int> a; // Declare an empty vector, a.
|
|
a.push_back(1); // Appends/Adds an element whose value is 1 to vector a.
|
|
std::cout << a.at(0) << std::endl; // Accessing index 0 of vector a.
|
|
a.size(); // Returns the size of the vector
|
|
a.at(0) = 420; // Changing the value at index 0 to 420.
|