问题
I know C++.
Anything other?
回答1:
Wikipedia's article on Operator Overloading features a list of languages that support it.
回答2:
I'm amused thinking about it. Any C compiler for example, must tell between an int *c;
and double d = (int) f * (float) g;
. In the former case, * indicates c is a pointer to int while in the latter case it is a multiplication operator. Though not exported outside the compiler itself, C appears to have operator overloading feature. C++ exported it outside the compiler?
I am sure other languages like Java should have some mechanism to tell + or * or such operators when they are used between various combinations and permutations of the types of the operands.
来源:https://stackoverflow.com/questions/2865526/which-programming-languages-other-than-c-support-operator-overloading