Skip to content

Instantly share code, notes, and snippets.

@duanescarlett
Created March 31, 2023 01:56
Show Gist options
  • Save duanescarlett/2ddb3719d519635a3993357a15d0e548 to your computer and use it in GitHub Desktop.
Save duanescarlett/2ddb3719d519635a3993357a15d0e548 to your computer and use it in GitHub Desktop.
Tutorial on inheritance
// 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