◆→"重载"一词是否有两个以上的意思?

jimconrad jimconrad 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
在c++教科书中,重载大概被解释为:C++允许在相同作用域中以相同的名字定义不同的函数,只要它们的参数(数量或类型)不同。

另一个重载是指操作符重载,在类内部对内建的操作符进行重定义:
With C++, you can redefine the function of most built-in operators. These operators can be redefined, or “overloaded,” globally or on a class-by-class basis. Overloaded operators are implemented as functions and can be class-member or global functions.

那么上面就有两层意思了:
1.在“相同”或“同一”或“same”的作用域内同一名称不同函数的现象称为重载,比如一个类内部有两个构造函数。
2.在一个大的作用域内包含的另一个小的作用域内,对大作用域的某个函数、运算符进行重定义的现象。

还有一个经常被人称为“重载”的意思就是:比如“重载基类的虚函数”中的“重载”。这里的重载其实是实现的意思;如果该虚函数贯穿的不只一个派生层次,其实也可以理解为“重定义”,即将父类中该函数的实现覆盖掉,重新写一个。那么这里的重载其实是描述“多态”的一个术语。

于是“重载”一词至少应当有三个意思。是吗?如果有面试官问:“什么是重载?”该作何回答?

如果我理解的概念有误,急盼指出,多谢!
...全文

相关推荐

java_jdk-8u161-windows-x64(jdk官方版本1.8)

官方下载的java jdk1.8官方版本 在官网加载速度很慢,CSDN下载速度很快。

张文靖同学

JDK1.8-windows-x64(官方WINDOW正式版)

The JDK is a development environment for building applications using the Java programming language. The JDK includes tools useful for developing and testing programs written in the Java programming language and running on the JavaTM platform. WARNING: These older versions of the JRE and JDK are provided to help developers debug issues in older systems. They are not updated with the latest security patches and are not recommended for use in production. For production use Oracle recommends downloading the latest JDK and JRE versions and allowing auto-update. Only developers and Enterprise administrators should download these releases. Downloading these releases requires an oracle.com account. If you don't have an oracle.com account you can use the links on the top of this page to learn more about it and register for one for free.

一叶飞舟

JDK1.8 64位 Windows 官方正式版(jdk-8u261-windows-x64)

Java SE 8u261 is the latest release for the Java SE 8 Platform JDK1.8 64位 Windows 官方正式版(jdk-8u261-windows-x64)

年少挽滑稽世无双

jdk-8u151-windows-x64.exe 【官方下载的jdk1.8、jdk8,windows 64位版】

jdk-8u151-windows-x64.exe 【官方下载的jdk1.8、jdk8,windows 64位版】。

有范管理美学

jdk1.8(windows-x64-8u271).zip

官方下载的JDK1.8。版本:windows-x64-8u271

骆驼(奋斗的码农)
评论 8
收藏 已收藏
分享
返回顶部
jimconrad
C语言 70,040 成员 243,237 内容