What is the real significance(use) of polymorphism

前端 未结 10 2337
别跟我提以往
别跟我提以往 2020-12-01 01:44

I am new to OOP. Though I understand what polymorphism is, but I can\'t get the real use of it. I can have functions with different name. Why should I try to implement polym

10条回答
  •  情歌与酒
    2020-12-01 02:22

    Have you ever added two integers with +, and then later added an integer to a floating-point number with +?

    Have you ever logged x.toString() to help you debug something?

    I think you probably already appreciate polymorphism, just without knowing the name.

提交回复
热议问题