I have a some knowledge of Python, OOP and some programming principles and I am currently trying to teach myself C++. However, I have a very weird, unexpected problem when trying to deal with multidimensional arrays. Basically, I have this code:
#include <iostream>
using namespace std;
int main() {
int a[2][2] = { {2, 3} , {4, 6} };
for (int i = 0; i < 2; i++) {
for (int y = 0; i < 2; y++) {
cout << a[i][y] << endl;
}
}
return 0;
}
It starts off great (returning 2, 4, 5, 6; but end up with many weird and seemingly random numbers). However, in Python the similar code:
a = [[2, 3], [4, 6]]
for i in range(2):
for y in range(2):
print a[i][y]
Only prints the more expected: 2, 3, 4, 6. Why? What am I doing wrong?
(Also, does anyone have any suggestions as to what projects are excellent for learning c++?)