Override and overload in C++

后端 未结 7 1491
生来不讨喜
生来不讨喜 2020-12-04 05:56

Yes, I do understand the difference between them. What I want to know is: why OVERRIDE a method? What is the good in doing it? In case of overload: the only advantage is you

7条回答
  •  再見小時候
    2020-12-04 06:06

    The textbook example is class Animal with method speak(). The Dog subclass overrides speak() to "bark" while the Cat subclass overrides speak() to "meow".

提交回复
热议问题