Created
December 29, 2022 15:16
-
-
Save BellaBe/b4e670c1aa8ad7cb7baa506ce228b8fc to your computer and use it in GitHub Desktop.
Parent child single inheritance Smart contract
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: MIT | |
pragma solidity ^0.8.13; | |
contract ParentContract{ | |
uint internal simpleInteger; | |
function setInteger(uint _value) external{ | |
simpleInteger = _value; | |
} | |
} | |
contract ChildContract is ParentContract{ | |
bool private simpleBool; | |
function getInteger() public view returns(uint){ | |
return simpleInteger; | |
} | |
} | |
contract Client { | |
ChildContract pc = new ChildContract(); | |
function workWithInheritance() public returns (uint){ | |
pc.setInteger(100); | |
return pc.getInteger(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment