由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 关于polymorphism和overloading
相关主题
another c++ question一个朋友刚去狗狗
请问如何准备C/C++面试C++ online Test 一题
一些oop的概念[合集] 碰上面试的老印是个白痴,倒霉
bloomberg online assessement (JAVA) 4amazon一面
【设计模式】要达到啥水平?abstraction vs encapsulation
amazon intern一共几面, 加面经在method中间有多个return会有什么后果吗?今天被boss说了。。
NeAp 面试题一道bloomberg面经
我撕去一小块窗纸,你能看到多远的天?小公司面经
相关话题的讨论汇总
话题: method话题: 多态话题: 父类
进入JobHunting版参与讨论
1 (共1页)
J*********n
发帖数: 370
1
不少书上将overloading说成是polymorphism的一种实现方式,但是wiki上有这段话
"Polymorphism is only concerned with the application of specific
implementations to an interface or a more generic base class. Method
overloading refers to methods that have the same name but different
signatures inside the same class. Method overriding is where a subclass
replaces the implementation of one or more of its parent's methods.
Neither method overloading nor method overriding are by themselves
implementations of polymorphism"
不过,这之前确实有这样一句话“(Subtype) polymorphism is not the same as method
overloading or method overriding [1], (that is known instead as ad-hoc polymorphism [2])”
从定义上看,polymorphism is the ability to allow objects of different types to
response to the same message, but display different behaviors.
我的理解是,多态主要表现在声明一个父类或者接口变量,然后将子类或者实现了那个接口
的对象赋给该变量时,不同的对象能对同个消息(或者方法调用)表现出不同的动作,从而
表现出多态,这让我们在写代码时通过对父类或者接口编程,能容易的实现程序的可扩展性
和可维护性。这同时也是动态绑定的实现方式。而重载并不需要通过父类或者接口变量来实
现,不具备上述的优点,所以称不上多态。
不知道大家对这个问题怎么理解
p**o
发帖数: 380
2
polymorphism in CS includes 3 general forms(according to wikipedia):
1. ad-hoc polymorphism <- function/method overloading
2. parametric polymorphism
3. subtype polymorphism <-- OO crap you are talking about
to discuss more, you have to specify the programming language as
well.

method
polymorphism [2])”

【在 J*********n 的大作中提到】
: 不少书上将overloading说成是polymorphism的一种实现方式,但是wiki上有这段话
: "Polymorphism is only concerned with the application of specific
: implementations to an interface or a more generic base class. Method
: overloading refers to methods that have the same name but different
: signatures inside the same class. Method overriding is where a subclass
: replaces the implementation of one or more of its parent's methods.
: Neither method overloading nor method overriding are by themselves
: implementations of polymorphism"
: 不过,这之前确实有这样一句话“(Subtype) polymorphism is not the same as method
: overloading or method overriding [1], (that is known instead as ad-hoc polymorphism [2])”

q****x
发帖数: 7404
3
可以是广义多态嘛。扣字眼没意思。

method
polymorphism [2])”

【在 J*********n 的大作中提到】
: 不少书上将overloading说成是polymorphism的一种实现方式,但是wiki上有这段话
: "Polymorphism is only concerned with the application of specific
: implementations to an interface or a more generic base class. Method
: overloading refers to methods that have the same name but different
: signatures inside the same class. Method overriding is where a subclass
: replaces the implementation of one or more of its parent's methods.
: Neither method overloading nor method overriding are by themselves
: implementations of polymorphism"
: 不过,这之前确实有这样一句话“(Subtype) polymorphism is not the same as method
: overloading or method overriding [1], (that is known instead as ad-hoc polymorphism [2])”

J*********n
发帖数: 370
4
好吧,通常人们说得应该是指第三种

【在 p**o 的大作中提到】
: polymorphism in CS includes 3 general forms(according to wikipedia):
: 1. ad-hoc polymorphism <- function/method overloading
: 2. parametric polymorphism
: 3. subtype polymorphism <-- OO crap you are talking about
: to discuss more, you have to specify the programming language as
: well.
:
: method
: polymorphism [2])”

J*********n
发帖数: 370
5
抠字眼....等你被问到,但不懂的时候你就不会觉得抠字眼了,呵呵

【在 q****x 的大作中提到】
: 可以是广义多态嘛。扣字眼没意思。
:
: method
: polymorphism [2])”

1 (共1页)
进入JobHunting版参与讨论
相关主题
小公司面经【设计模式】要达到啥水平?
昨天的二轮电面amazon intern一共几面, 加面经
Amazon首轮电面SDETNeAp 面试题一道
BB店面经我撕去一小块窗纸,你能看到多远的天?
another c++ question一个朋友刚去狗狗
请问如何准备C/C++面试C++ online Test 一题
一些oop的概念[合集] 碰上面试的老印是个白痴,倒霉
bloomberg online assessement (JAVA) 4amazon一面
相关话题的讨论汇总
话题: method话题: 多态话题: 父类