vendredi 3 février 2017

Why (1+3)[a] is the same as a[1+3]?

While studying 18 Essential C++ Interview Questions, I found a question with the following (strange) statement:

std::cout << (1 + 3)[a] - a[0] + (a + 1)[2];

The answer then explained, (1+3)[a] is the same as a[1+3], which is still strange for me.

May I ask for the history of this? Why it's so and how it helps to allow this?

Aucun commentaire:

Enregistrer un commentaire