There is my code
int array[3][4] = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9}
};
for (auto line : array)
// something
Why the type of line is int * instead of int (*)[4]?
I have looked for reference about the range-based for loop, and I'm using C++ 11, so the corresponding source code is
{
auto && __range = range_expression ;
for (auto __begin = begin_expr, __end = end_expr; __begin != __end; ++__begin) {
range_declaration = *__begin;
loop_statement
}
According to the first item of the Explanation:
If range_expression is an expression of array type, then begin_expr is
__range
so there is a satement __begin = range_expression, and it equal to auto line = array.
and then the type of line is int (*)[4], but in fact it's int *?
Why? Could anybody help me?