Override vs Overload

Summary

In this post, I will introduce function override and function overload in C++, which are introduced by polymorphism in object oriented programming.

Conclusion

Overload

  1. Function overloadding achieves at compile time.
  2. It provides multiple definitions of the function by changing signature. Changing signatures includes changing number of parameters, change datatype of parameters. Note that return type doesn’t play anyrole.
  3. Overloading can occur without inheritance.
  4. Chinese: 方法重载.

Override

  1. Function Overridding achieves at run time.
  2. It is the redefinition of base class function in its derived class with same signature i.e return type and parameters.
  3. Chinese: 方法重写.

Leave a Reply

Your email address will not be published. Required fields are marked *