Answers for "vector of vector cpp"

C++
36

c++ vector

#include <vector>

int main() {
  std::vector<int> v;
  v.push_back(10); // v = [10];
  v.push_back(20); // v = [10, 20];
  
  v.pop_back(); // v = [10];
  v.push_back(30); // v = [10, 30];
  
  auto it = v.begin();
  int x = *it; // x = 10;
  ++it;
  int y = *it; // y = 30
  ++it;
  bool is_end = it == v.end(); // is_end = true
  
  return 0;
}
Posted by: Guest on March-17-2020
1

vector of vectors c++

vector<vector<int>> matrix(x, vector<int>(y));

This creates x vectors of size y, filled with 0's.
Posted by: Guest on May-06-2021
0

vector of vectors c++

vector<vector<data_type>> vec;
Posted by: Guest on May-06-2021

Browse Popular Code Answers by Language