I am getting an error while compiling the following cpp code:
int x[][2]{{1, 2}, {3, 4}};
for (int e[2] : x) {
std::cout << e[0] << ' ' << e[1] << '\n';
}
This gives the following error:
error: array must be initialized with a brace-enclosed initializer
I did replaced int e[2] with auto e and that worked but I want to work with the actual type.
Is there any workaround?
std::array