函数重载是c ++中多态的一部分吗? [英] Is function overloading a part of polymorphism in c++?

查看:188
本文介绍了函数重载是c ++中多态的一部分吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

函数overroding肯定是多态的。我想知道函数重载是否也是多态的。我的意思是在函数重载中,我们编写多个具有相同名称的函数,每个函数都有自己的功能。多态性具有相似的概念。请帮我澄清。

The function overroding is certainly polymorphism. I wonder if function overloading is polymorphism too. I mean in function overloading we write multiple function with same name each with it's own functioning. The polymorphism have the similar concept. Please help me clearify.

推荐答案

hi,

提供了很好的解释 here [ ^ ]。



希望它有所帮助!!

Good explanation provided here[^].

hope it helps !!


不,这些是单独的概念。在多态性中,可以通过派生共享其基类的一部分行为并改变或添加一些其他行为的子类来使一类对象多样化。这会创建一个类似树的层次结构。



相比之下,函数重载只是对具有不同参数集的多个函数使用相同的函数名。没有涉及继承,因此具有相同名称的函数集不构成层次结构。
No, these are separate concepts. In polymorphism one class of objects may be diversified by deriving subclasses that share part of the behavior of their base class and change or add some other behavior. That creates a tree-like hierarchy of classes.

In contrast, function overloading just uses the same function name for multiple functions with different argument sets. There is no inheritance involved and hence the set of functions with same name does not form a hierarchy.


这篇关于函数重载是c ++中多态的一部分吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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