Hacker News new | ask | show | jobs
by kevincox 1900 days ago
How does this work in C++ with operator overloading. Are they still the same? That would make for some interesting obfuscated code.
2 comments

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++.