answersLogoWhite

0

Overloading means to provide more than one function with the same function name in the same namespace. Overloaded functions must differ in the number and/or type of arguments they accept. The number and type of arguments constitutes the function signature, which is used to differentiate them. That is, the number and type of arguments you pass determine which instance of the function is called. The return value is not part of the signature, thus overloads cannot differ by return type alone.

Overriding relates to virtual functions where derived classes can provide more specialised implementations of generic methods. When you call the generic base class method implicitly, the most-derived override is called automatically, thus ensuring polymorphic behaviour; objects behave according to their actual type, even when the actual type cannot be determined in advance and without the need for expensive runtime type information. While a base class may be designed to be aware of some of its derivatives, it cannot be made aware of all its derivatives since new derivatives could be created at any time, by anyone with access to the base class definition. Overriding virtual functions ensures that base classes do not need to know anything about any of their derivatives, thus reducing the need for unnecessary coupling.

User Avatar

Wiki User

11y ago

What else can I help you with?