Hacker News new | past | comments | ask | show | jobs | submit login

How does this work in C++ with operator overloading. Are they still the same? That would make for some interesting obfuscated code.



No, they're not. It works by: if either a or b in a[b] is a class/enumeration type, call a.operator[](b).


> How does this work in C++ with operator overloading.

you can't overload int::operator[](...)


I guess the question was whether the subscript operator is always assumed commutative in C++.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: