Having code:
int** a = new int*[2];
a[0] = new int(1);
a[1] = new int(2);
cout << "a[0] " << a[0] << '\n';
cout << "a[1] " << a[1] << '\n';
cout << "a[2] " << a[2] << '\n';
cout << "a[0] + 1 " << a[0] + 1 << '\n';//WHY THIS ISN'T == a[1] ?
cout << "*(a + 1): " << *(a + 1) << '\n'; //WHY THIS IS == a[1] ?
cout << "a[0] - a[1] " << static_cast<int>(a[0] - a[1])<< '\n';//WHY THIS IS == 16 not 4?
cout << sizeof(int**);
Questions are included right next to relevant lines in code.
a[0] + 1means that 1 is added to the value stored ina[0]*(a + 1)means that1 * sizeof(int)is added to the memory address of a, and then the value at that location is accessed, meaning you geta[1]Read more about pointers here.
As for your last question, there is no guarantee it will print any specific value, since the two memory addresses do not have to be contiguous. For me it prints
-4for example.