r/ProgrammerTIL • • Sep 14 '17

Other [c++] Array declarations are commutative/invertible.

array[4] is equivalent to 4[array]. Not that you would ever really use it.

43 Upvotes

14 comments sorted by

View all comments

Show parent comment

1

u/Tarrjue Sep 14 '17

Even without the typing, this probably wouldn't work. You would almost certainly run into a seg fault.

2

u/GiantRobotTRex Sep 14 '17

Either 3 or 4 would probably be replaced by the fixed address of a hardware device or something.