Created
March 31, 2023 01:56
-
-
Save duanescarlett/2ddb3719d519635a3993357a15d0e548 to your computer and use it in GitHub Desktop.
Tutorial on inheritance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.17; | |
contract Parent { | |
function foo() public pure virtual returns (string memory) { | |
return "A"; | |
} | |
function bar() public pure virtual returns (string memory) { | |
return "B"; | |
} | |
function available() public pure returns (string memory) { | |
return "Yes"; | |
} | |
} | |
contract Child is Parent { | |
function foo() public pure override returns (string memory) { | |
return "B"; | |
} | |
function bar() public pure virtual override returns (string memory) { | |
return "A"; | |
} | |
} | |
contract GrandChild is Child { | |
function bar () public pure override returns (string memory) { | |
return "Grand child"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment