Difference between overloading and overriding?
Answer:
1. Overload - two functions that appear in the same scope are overloaded if they have the same name but have different parameter list.
2. main( ) cannot be overloaded.
3. notational convenience - compiler invokes the functions that is the best match on the args – found by finding the best match between the type of arguments expression and parameter.
4. if declare a function locally, that function hides rather than overload the same function declared in an outer scope.
5. Overriding - the ability of the inherited class rewriting the virtual method of a base class - a method which completely replaces base class FUNCTIONALITY in subclass.
6. the overriding method in the subclass must have exactly the same signature as the function of the base class it is replacing - replacement of a method in a child class.
7. writing a different body in a derived class for a function defined in a base class, ONLY if the function in the base class is virtual and ONLY if the function in the derived class has the same signature.
8. all functions in the derived class hide the base class functions with the same name except in the case of a virtual functions which override the base class functions with the same signature




Leave a Reply
You must be logged in to post a comment.