What is the difference between "overloading" and "overriding"?

Overloading is the practice of supplying more than one definition for a given function name in the same scope. The compiler is left to pick the appropriate version of the function or operator based on the arguments with which it is called. Overriding refers to the virtual functions, i.e. functions that ensure that the correct function is called for an object, regardless of the expression used to make the function call. For example, if the same function with virtual attribute is declared in base and derived class, the function from the derived class is invoked for objects of the derived class, even if it is called using a pointer or reference to the base class.

No comments: