Solidity Series

Solidity Programming Language – Overriding Parent Function in Multiple Inheritance

In Solidity, when you have multiple inheritance and two or more parent contracts define a function with the same name and signature, you can override the function in the derived contract to specify which parent’s implementation should be used. Here’s how you can override a parent function in a derived contract with multiple inheritance.

By explicitly specifying which parent function to override, you can resolve the ambiguity caused by multiple inheritance and provide specific implementations for each overridden function in the derived contract.

Code:

Output:

Hi, I’m saksham dixit

Leave a Reply

Your email address will not be published. Required fields are marked *