What is the difference between override and overload?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Overloading: picking a method signature at compile time based on the number and type of the arguments specified
Overriding: picking a method implementation at execution time based on the actual type of the target object (as opposed to the compile-time type of the expression)
For example:
Both calls are examples of overloading. There are two methods called
foo, and the compiler determines which signature to call.The first call is an example of overriding. The compiler picks the signature “foo(int)” but then at execution time, the type of the target object determines that the implementation to use should be the one in
Child.