5 ms·
>The behavior of [] is from C -- it's not a bizarro C++ feature. I'd say that a feature of C++ is still a feature of C++ even if the same feature is in C.
by nawitus 14y ago
>The behavior of [] is from C -- it's not a bizarro C++ feature.
I'd say that a feature of C++ is still a feature of C++ even if the same feature is in C.
- _pmf_ 14y agoThe point was probably that it is not obscure; it's what you had to learn when using plain C in the first week.
- Poyeyo 14y agoAnd the next week, and six months after that, again.
- eswangren 14y agoSeriously? It's not a difficult concept to understand...
- ycombobreaker 14y agoWhile it's definitely a rarely-used feature, the equivalence a[b] == *(a + b) == b[a] is fundamental to pointer math. Once you grok pointer math, then this is an interesting bit of syntax trivia and should not be forgotten easily.
- axusgrad 14y agocalling a[5] isn't obscure, but 5[a] sure is!
- papsosouid 14y agoExcept you didn't have to learn it as part of learning C, you didn't have to learn C to learn C++, and I would bet 99% of C and C++ programmers have no idea that 5[p] is valid code.