除C ++之外,哪些编程语言支持运算符重载? [英] Which programming languages, other than C++, support operator overloading?

查看:90
本文介绍了除C ++之外,哪些编程语言支持运算符重载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解C ++.

还有其他吗?

推荐答案

我对此感到很有趣.例如,任何C编译器都必须在int *c;double d = (int) f * (float) g;之间进行区分.在前一种情况下,*表示c是指向int的指针,而在后一种情况下,它表示是乘法运算符.尽管没有导出到编译器本身之外,但C似乎具有运算符重载功能. C ++将其导出到编译器之外?

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?

我确信像Java之类的其他语言应具有某种机制来告知+或*或此类运算符,何时在操作数类型的各种组合和排列之间使用它们.

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.

这篇关于除C ++之外,哪些编程语言支持运算符重载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆