Last active
June 20, 2022 11:28
-
-
Save alexpanasUCLA/83a9f9a41d85894a9f70baa0e38c2cb1 to your computer and use it in GitHub Desktop.
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.7.0; | |
// Defining parent contract | |
contract School { | |
// Declaring variable in the parent contract | |
string public school = "Shmorse School of Solidity"; | |
// Saves address of the wallet that deployed the contract | |
// Can be used in the future | |
address private _owner; | |
constructor (){ | |
_owner = msg.sender; | |
} | |
} | |
// Defining child contract that inherits from parent | |
contract Pupil is School{ | |
// Name of a pupil | |
string public name; | |
constructor (string memory name_){ | |
name = name_; | |
} | |
// Solidity does not like strings | |
// But we use it for simplicity | |
function concatenate() public view returns (string memory){ | |
return string(abi.encodePacked(name,' studies at ',school)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment