I consider overloading and overriding 2 magic tricks by the compiler. Here are a few contrasts as far as I can see.
Example of overloading —
– Overloading is compile-time magic; overriding is run-time magic. If you have a D object’s address in a variable myVar and you pass it function1, which function1 is chosen by compiler? Depends on the declared type of myVar. Discussed repeatedly in my blog.
– consider renaming to function1_for_Base()/function1_for_Derived() etc. It may seem cool to have a bunch of overload functions, but in one Barcap email sender utility class, there are 4 send(…) utilities each with more than 7 parameters — code smell. It’s hard for users to tell them apart. P403 [[c++TimesavingTechniques]] points out that overloading complicates debugging and maintenance.
** Readability is fine in overRiding
– Overriding is generally a best practice to be adopted whenever possible. I can’t say the same about overloading.
– c++ has hiding rule about overLoading. No such thing about overRiding.
– c++ does implicit (!) type conversion about overLoading.
– In conclusion, overriding is cleaner than overloading, less complicated, and more readable.
– In overriding There’s more magic by compiler — vptr etc. More powerful but Not more complicated
– overLoad can be applied to operators such as op=, op+. I doubt overRide can