1int** arr = new int*[10]; // Number of Students
2int i=0, j;
3for (i; i<10; i++)
4 arr[i] = new int[5]; // Number of Courses
5/*In line[1], you're creating an array which can store the addresses
6 of 10 arrays. In line[4], you're allocating memories for the
7 array addresses you've stored in the array 'arr'. So it comes out
8 to be a 10 x 5 array. */
1// Initializing 2D vector "vect" with
2// values
3vector<vector<int> > vect{ { 1, 2, 3 },
4 { 4, 5, 6 },
5 { 7, 8, 9 } };
1void printMatrix(array<array<int, COLS>, ROWS> matrix){
2for (auto row : matrix){
3//auto infers that row is of type array<int, COLS>
4for (auto element : row){
5cout << element << ' ';
6}
7cout << endl;
8}
1#include <array>
22 #include <iostream>
33
44 using namespace std;
55
66 //remember const!
77 const int ROWS = 2;
88 const int COLS = 3;
9
10
11int main(){
12 array<array<int, COLS>, ROWS> matrix = {
13 1, 2, 3,
14 4, 5, 6
15 };
16
17
18 return 0;
19}