vector with size code example
Example 1: initialize 3d vector c++
vector<vector<vector<double>>> f(3, vector<vector<double>>(4, vector<double>(5)));
Example 2: c++ vector size
#include <vector>
int main() {
std::vector<int> myVector = { 666, 1337, 420 };
size_t size = myVector.size();
myVector.push_back(399);
size = myVector.size();
}
Example 3: c++ create vector of size
std::vector<int> arr(20);
for(int x = 0; x < 20; ++x)
arr[x] = x;
Example 4: declare vector of size n in c++
#include <vector>
auto n = 20
std::vector<int> arr(n);