Skip to content

Instantly share code, notes, and snippets.

@alexpanasUCLA
Last active June 20, 2022 11:28
Show Gist options
  • Save alexpanasUCLA/83a9f9a41d85894a9f70baa0e38c2cb1 to your computer and use it in GitHub Desktop.
Save alexpanasUCLA/83a9f9a41d85894a9f70baa0e38c2cb1 to your computer and use it in GitHub Desktop.
// 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