Method overriding
Method overriding is the process of redefining a function available in the parent contract with the same name and signature in the derived contract. A parent contract contains two functions, SetInteger
and GetInteger
. A child contract inherits from the parent contract and implements GetInteger
by overriding the function.
Now, when a call to the GetInteger
function is made on the child contract, even while using a parent contract variable, the child contract instance function is invoked. This is because all functions in contracts are virtual and based on a contract instance; the most derived function is invoked.