0

Here is the code:

        int a[2][4] = {
            {3,   6,  9, 12},
            {15, 18, 21, 24}
        };
        std::cout << 2[1[a]] <<std::endl;

the output is 21, which means 2[1[a]] is equal to the expression a[1][2].

I also try other expressions, and the result is same. num2[num1[a]] is equal to a[num1][num2] .

My question is, which book or reference says it works?

  • 1
    https://stackoverflow.com/questions/5546075/different-way-of-accessing-array-elements-in-c – shawn Feb 15 '20 at 08:50
  • Which book or reference says it works? The C++ standard is the authoritative definition of C++ - the purpose of the standard is defining the basis for assessing correctness of implementations (i.e. compilers and standard libraries). For example, the 1998 C++ standard is the yardstick against which correctness of C++98 implementations are assessed, the 2017 C++ standard is the yardstick against which correctness of C++17 implementations are assessed. – Peter Feb 15 '20 at 09:21

0 Answers0